Decimal - Remainder

Computes the remainder after dividing two values.

Try it

public static void Main()
{
    // Create parallel arrays of Decimals to use as the dividend and divisor.
    Decimal[] dividends = { 79m, 1000m, -1000m, 123m, 1234567800000m, 1234.0123m };
    Decimal[] divisors = { 11m, 7m, 7m, .00123m, 0.12345678m, 1234.5678m };

    for (int ctr = 0; ctr < dividends.Length; ctr++)
    {
        Decimal dividend = dividends[ctr];
        Decimal divisor = divisors[ctr];
		
		// C# Extension Method: Decimal - Remainder
		Decimal remainder = dividend.Remainder(divisor);
        Console.WriteLine("{0}/{1} = {2}", dividend, divisor, remainder);
    }
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     Computes the remainder after dividing two  values.
    /// </summary>
    /// <param name="d1">The dividend.</param>
    /// <param name="d2">The divisor.</param>
    /// <returns>The remainder after dividing  by .</returns>
    public static Decimal Remainder(this Decimal d1, Decimal d2)
    {
        return Decimal.Remainder(d1, d2);
    }
}