BigInteger.Add(BigInteger, BigInteger) Método

Definição

Adiciona dois valores de BigInteger e retorna o resultado.

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

Parâmetros

left
BigInteger

O primeiro valor a ser adicionado.

right
BigInteger

O segundo valor a ser adicionado.

Retornos

A soma de left e right.

Comentários

Idiomas que não dão suporte a sobrecarga de operador ou operadores personalizados podem usar o Add método para executar adição usando BigInteger valores.

O Add método é um substituto útil para o operador de adição ao instanciar uma BigInteger variável atribuindo-lhe uma soma resultante da adição, conforme mostrado no exemplo a seguir.

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

Aplica-se a

Confira também