0 out of 1 rated this helpful - Rate this topic

# Decimal.Remainder Method

.NET Framework 4.5

Computes the remainder after dividing two Decimal values.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
```'Declaration
Public Shared Function Remainder ( _
d1 As Decimal, _
d2 As Decimal _
) As Decimal
```

#### Parameters

d1
Type: System.Decimal

The dividend.

d2
Type: System.Decimal

The divisor.

#### Return Value

Type: System.Decimal
The remainder after dividing d1 by d2.
ExceptionCondition
DivideByZeroException

d2 is zero.

OverflowException

The return value is less than MinValue or greater than MaxValue.

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

```Module Example
Sub Main( )
' Create parallel arrays of Decimals to use as the dividend and divisor.
Dim dividends() As Decimal = { 79d, 1000d, -1000d, 123d, 1234567800000d,
1234.0123d }
Dim divisors() As Decimal = { 11d, 7d, 7d, .00123d, 0.12345678d,
1234.5678d }

For ctr As Integer = 0 To dividends.Length - 1
Dim dividend As Decimal = dividends(ctr)
Dim divisor As Decimal = divisors(ctr)
Console.WriteLine("{0:N3} / {1:N3} = {2:N3} Remainder {3:N3}", dividend,
divisor, Decimal.Divide(dividend, divisor),
Decimal.Remainder(dividend, divisor))
Next
End Sub
End Module
' The example displays the following output:
'       79.000 / 11.000 = 7.182 Remainder 2.000
'       1,000.000 / 7.000 = 142.857 Remainder 6.000
'       -1,000.000 / 7.000 = -142.857 Remainder -6.000
'       123.000 / 0.001 = 100,000.000 Remainder 0.000
'       1,234,567,800,000.000 / 0.123 = 10,000,000,000,000.000 Remainder 0.000
'       1,234.012 / 1,234.568 = 1.000 Remainder 1,234.012
```

#### .NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

#### .NET Framework Client Profile

Supported in: 4, 3.5 SP1

#### Portable Class Library

Supported in: Portable Class Library

#### .NET for Windows Store apps

Supported in: Windows 8

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.