Decimal.Add Method

Adds two specified Decimal values.

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

[SecuritySafeCriticalAttribute]
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;
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: