Condividi tramite


BigInteger.Add(BigInteger, BigInteger) Metodo

Definizione

Somma due valori BigInteger e restituisce il risultato.

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

Parametri

left
BigInteger

Primo valore da sommare.

right
BigInteger

Secondo valore da sommare.

Valori restituiti

Somma di left e right.

Commenti

I linguaggi che non supportano l'overload degli operatori o gli operatori personalizzati possono usare il metodo per eseguire l'aggiunta Add usando BigInteger i valori.

Il Add metodo è una sostituzione utile per l'operatore di aggiunta quando si crea un'istanza di una BigInteger variabile assegnando una somma risultante dall'aggiunta, come illustrato nell'esempio seguente.

// 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)

Si applica a

Vedi anche