C# Decimal Subtraction

Description

Decimal Subtraction subtracts two specified Decimal values.

Syntax

Decimal.Subtraction has the following syntax.


public static decimal operator -(
  decimal d1,
  decimal d2
)

Parameters

Decimal.Subtraction has the following parameters.

  • d1 - The minuend.
  • d2 - The subtrahend.

Returns

Decimal.Subtraction method returns The result of subtracting d2 from d1.

Example

The Subtraction method defines the operation of the subtraction operator for Decimal values. It enables code such as the following:


using System;//from www. j av  a  2s .  c o  m

public class Example
{
   public static void Main()
   {
      Decimal number1 = 120.07m;
      Decimal number2 = 163.19m;
      Decimal number3 = number1 - number2;
      Console.WriteLine(number3);
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version