.NET Framework 1.1

Adds two specified Decimal values.

```[Visual Basic]
Public Shared Function Add( _
ByVal d1 As Decimal, _
ByVal d2 As Decimal _
) As Decimal
[C#]
public static decimal Add(
decimal d1,
decimal d2
);
[C++]
public: static Decimal Add(
Decimal d1,
Decimal d2
);
[JScript]
public static function Add(
d1 : Decimal,
d2 : Decimal
) : Decimal;```

d1
A Decimal.
d2
A Decimal.

Return Value

A Decimal value that is the sum of d1 and d2.

Exceptions

Exception Type Condition
OverflowException The sum of d1 and d2 is less than MinValue or greater than MaxValue.

Remarks

The following code sample illustrates the use of Add:

```[Visual Basic]
Class PiggyBank

MyFortune = [Decimal].Add(MyFortune, 0.01D)
End Sub

Public Overrides Function ToString() As String
Return MyFortune.ToString("C") + " in piggy bank"
End Function

Protected MyFortune As Decimal
End Class

[C#]
class PiggyBank {
public void AddPenny() {
MyFortune = Decimal.Add(MyFortune, .01m);
}

public override string ToString() {
return MyFortune.ToString("C")+" in piggy bank";
}

protected decimal MyFortune;
}

[C++]
public __gc class PiggyBank {
public:
MyFortune = Decimal::Add(MyFortune, .01);
}

System::String* ToString() {
return String::Concat(MyFortune.ToString("C"),S" in piggy bank");
}

protected:
Decimal MyFortune;
};

[JScript]
class PiggyBank {
protected var MyFortune : Decimal;

public function AddPenny() {
MyFortune = Decimal.Add(MyFortune, 0.01);
}

public function ToString() : String {
return MyFortune.ToString("C")+" in piggy bank";
}
}
```

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard