C# Decimal Add

Description

Decimal Add adds two specified Decimal values.

Syntax

Decimal.Add has the following syntax.


public static decimal Add(
  decimal d1,
  decimal d2
)

Parameters

Decimal.Add has the following parameters.

  • d1 - The first value to add.
  • d2 - The second value to add.

Returns

Decimal.Add method returns The sum of d1 and d2.

Example

The following code sample illustrates the use of Add :


using System;//from   w w  w  .j ava  2 s .  c  om
class MyClass{
  public void Main() {
      decimal MyFortune;
    MyFortune = Decimal.Add(12M, .01m);
    System.Console.WriteLine(MyFortune.ToString("C"));
  }
}

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