Subtract Method

Decimal.Subtract Method

Subtracts one specified Decimal value from another.

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

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


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