Decimal.Add Method (Decimal, Decimal)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Adds two specified Decimal values.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

Public Shared Function Add (
	d1 As Decimal,
	d2 As Decimal
) As Decimal

Parameters

d1
Type: System.Decimal

The first value to add.

d2
Type: System.Decimal

The second value to add.

Return Value

Type: System.Decimal

The sum of d1 and d2.

Exception Condition
OverflowException

The sum of d1 and d2 is less than MinValue or greater than MaxValue.

The following code sample illustrates the use of Add :

Class PiggyBank

    Public Sub AddPenny()
        MyFortune = [Decimal].Add(MyFortune, 0.01D)
    End Sub

    Public Overrides Function ToString() As String
        Return MyFortune.ToString("C") + " in piggy bank"
    End Function

    Protected MyFortune As Decimal
End Class

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: