C# Decimal Addition
Description
Decimal Addition
adds two specified Decimal values.
Syntax
Decimal.Addition
has the following syntax.
public static decimal operator +(
decimal d1,
decimal d2
)
Parameters
Decimal.Addition
has the following parameters.
d1
- The first value to add.d2
- The second value to add.
Returns
Decimal.Addition
method returns The result of adding d1 and d2.
Example
The Addition method defines the operation of the addition operator for Decimal values. It enables code such as the following:
using System;/* w ww . ja v a2 s. com*/
public class Example
{
public static void Main()
{
Decimal number1 = 120.07m;
Decimal number2 = 163.19m;
Decimal number3 = number1 + number2;
Console.WriteLine("{0} + {1} = {2}",
number1, number2, number3);
}
}
The code above generates the following result.