BigInteger.Add(BigInteger, BigInteger) Metodo

Definizione

Aggiunge due BigInteger valori 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 aggiungere.

right
BigInteger

Secondo valore da aggiungere.

Valori restituiti

Somma di left e right.

Commenti

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

Il Add metodo è un utile sostituto dell'operatore di addizione 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