Decimal.Add Method

May 11, 2014

Adds two specified Decimal values.

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

public static decimal Add(
	decimal d1,
	decimal d2
)

Parameters

d1
Type: System.Decimal
A Decimal.
d2
Type: System.Decimal
A Decimal.

Return Value

Type: System.Decimal
A Decimal value that is the sum of d1 and d2.

ExceptionCondition
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 void AddPenny()
   {
      MyFortune = Decimal.Add(MyFortune, .01m);
   }

   public override string ToString()
   {
      return MyFortune.ToString("C") + " in piggy bank";
   }

   protected decimal MyFortune;
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft