C# Decimal Remainder

Description

Decimal Remainder computes the remainder after dividing two Decimal values.

Syntax

Decimal.Remainder has the following syntax.


public static decimal Remainder(
  decimal d1,
  decimal d2
)

Parameters

Decimal.Remainder has the following parameters.

  • d1 - The dividend.
  • d2 - The divisor.

Returns

Decimal.Remainder method returns The remainder after dividing d1 by d2.

Example

The following example uses the Remainder method to calculate the remainder in a series of division operations.


using System;/*w  ww  . j  a va  2s . com*/

public class Example
{
    public static void Main()
    {
           Decimal dividend = 3M;
           Decimal divisor = 2M;
           Console.WriteLine(Decimal.Remainder(dividend, divisor)); 
    }
} 

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version