BigInteger.Add Method

Adds two BigInteger values and returns the result.

Namespace:  System.Numerics
Assemblies:   System.Runtime.Numerics (in System.Runtime.Numerics.dll)
  System.Numerics (in System.Numerics.dll)

public static BigInteger Add(
	BigInteger left,
	BigInteger right
)

Parameters

left
Type: System.Numerics.BigInteger

The first value to add.

right
Type: System.Numerics.BigInteger

The second value to add.

Return Value

Type: System.Numerics.BigInteger
The sum of left and right.

Languages that do not support operator overloading or custom operators can use the Add method to perform addition using BigInteger values.

The Add method is a useful substitute for the addition operator when instantiating a BigInteger variable by assigning it a sum that results from addition, as shown in the following example.

// The statement: 
//    BigInteger number = Int64.MaxValue + Int32.MaxValue; 
// produces compiler error CS0220: The operation overflows at compile time in checked mode. 
// The alternative:
BigInteger number = BigInteger.Add(Int64.MaxValue, Int32.MaxValue);

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

.NET for Windows Phone apps

Supported in: Windows Phone 8.1

Portable Class Library

Supported in: Portable Class Library
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft