Subtract Method

Decimal.Subtract Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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:
© 2017 Microsoft