BigInteger.Add(BigInteger, BigInteger) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
相加兩個 BigInteger 值並回傳結果。
public:
static System::Numerics::BigInteger Add(System::Numerics::BigInteger left, System::Numerics::BigInteger right);
public static System.Numerics.BigInteger Add(System.Numerics.BigInteger left, System.Numerics.BigInteger right);
static member Add : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
Public Shared Function Add (left As BigInteger, right As BigInteger) As BigInteger
參數
- left
- BigInteger
這是第一個要補充的價值。
- right
- BigInteger
第二個值得加的價值。
傳回
left 和 right 的總和。
備註
不支援運算子重載或自訂運算子的語言,可以使用此 Add 方法使用值 BigInteger 進行加法。
此 Add 方法是在實 BigInteger 例化變數時,透過指派一個由加法得到的和來實例化變數,作為加法運算子的有用替代,如下範例所示。
// 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);
let number = BigInteger.Add(Int64.MaxValue, Int32.MaxValue);
' The statement
' Dim number As BigInteger = Int64.MaxValue + Int32.MaxValue
' produces compiler error BC30439: Constant expression not representable in type 'Long'.
' The alternative:
Dim number As BigInteger = BigInteger.Add(Int64.MaxValue, Int32.MaxValue)