Decimal.Subtract Method

July 28, 2014

Subtracts one specified Decimal value from another.

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

public static decimal Subtract(
	decimal d1,
	decimal d2
)

Parameters

d1
Type: System.Decimal
A Decimal (the minuend).
d2
Type: System.Decimal
A Decimal (the subtrahend).

Return Value

Type: System.Decimal
The Decimal result of subtracting d2 from d1.

ExceptionCondition
OverflowException

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

The following example illustrates the use of Subtract.


class PiggyBank
{
   public decimal Cents
   {
      get
      {
         return Decimal.Subtract(MyFortune, Decimal.Floor(MyFortune));
      }
   }

   protected decimal MyFortune;

   public void AddPenny()
   {
      MyFortune += .01m;
   }
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft