Interlocked.Add Método
Definição
Adiciona dois números inteiros e substitui o primeiro inteiro com a soma, como uma operação atômica.Adds two integers and replaces the first integer with the sum, as an atomic operation.
Sobrecargas
Add(Int32, Int32) |
Adiciona dois números inteiros de 32 bits e substitui o primeiro inteiro com a soma, como uma operação atômica.Adds two 32-bit integers and replaces the first integer with the sum, as an atomic operation. |
Add(Int64, Int64) |
Adiciona dois números inteiros de 64 bits e substitui o primeiro inteiro com a soma, como uma operação atômica.Adds two 64-bit integers and replaces the first integer with the sum, as an atomic operation. |
Add(UInt32, UInt32) |
Adiciona dois números inteiros sem sinal de 32 bits e substitui o primeiro inteiro pela soma, como uma operação atômica.Adds two 32-bit unsigned integers and replaces the first integer with the sum, as an atomic operation. |
Add(UInt64, UInt64) |
Adiciona dois números inteiros sem sinal de 64 bits e substitui o primeiro inteiro pela soma, como uma operação atômica.Adds two 64-bit unsigned integers and replaces the first integer with the sum, as an atomic operation. |
Add(Int32, Int32)
Adiciona dois números inteiros de 32 bits e substitui o primeiro inteiro com a soma, como uma operação atômica.Adds two 32-bit integers and replaces the first integer with the sum, as an atomic operation.
public:
static int Add(int % location1, int value);
public static int Add (ref int location1, int value);
static member Add : int * int -> int
Public Shared Function Add (ByRef location1 As Integer, value As Integer) As Integer
Parâmetros
- location1
- Int32
Uma variável que contém o primeiro valor a ser adicionado.A variable containing the first value to be added. A soma dos dois valores é armazenada em location1
.The sum of the two values is stored in location1
.
- value
- Int32
O valor a ser adicionado ao inteiro em location1
.The value to be added to the integer at location1
.
Retornos
O novo valor armazenado em location1
.The new value stored at location1
.
Exceções
O endereço de location1
é um ponteiro nulo.The address of location1
is a null pointer.
Comentários
Esse método manipula uma condição de estouro por encapsulamento: se o valor em location1
for Int32.MaxValue e value
for 1, o resultado será Int32.MinValue ; se value
for 2, o resultado será ( Int32.MinValue + 1); e assim por diante.This method handles an overflow condition by wrapping: if the value at location1
is Int32.MaxValue and value
is 1, the result is Int32.MinValue; if value
is 2, the result is (Int32.MinValue + 1); and so on. Nenhuma exceção é lançada.No exception is thrown.
Confira também
- Threading gerenciadoManaged Threading
- Visão geral dos primitivos de sincronizaçãoOverview of synchronization primitives
Aplica-se a
Add(Int64, Int64)
Adiciona dois números inteiros de 64 bits e substitui o primeiro inteiro com a soma, como uma operação atômica.Adds two 64-bit integers and replaces the first integer with the sum, as an atomic operation.
public:
static long Add(long % location1, long value);
public static long Add (ref long location1, long value);
static member Add : int64 * int64 -> int64
Public Shared Function Add (ByRef location1 As Long, value As Long) As Long
Parâmetros
- location1
- Int64
Uma variável que contém o primeiro valor a ser adicionado.A variable containing the first value to be added. A soma dos dois valores é armazenada em location1
.The sum of the two values is stored in location1
.
- value
- Int64
O valor a ser adicionado ao inteiro em location1
.The value to be added to the integer at location1
.
Retornos
O novo valor armazenado em location1
.The new value stored at location1
.
Exceções
O endereço de location1
é um ponteiro nulo.The address of location1
is a null pointer.
Comentários
Esse método manipula uma condição de estouro por encapsulamento: se o valor em location1
for Int64.MaxValue e value
for 1, o resultado será Int64.MinValue ; se value
for 2, o resultado será ( Int64.MinValue + 1); e assim por diante.This method handles an overflow condition by wrapping: if the value at location1
is Int64.MaxValue and value
is 1, the result is Int64.MinValue; if value
is 2, the result is (Int64.MinValue + 1); and so on. Nenhuma exceção é lançada.No exception is thrown.
Confira também
- Increment
- Decrement
- Read(Int64)
- Threading gerenciadoManaged Threading
- Visão geral dos primitivos de sincronizaçãoOverview of synchronization primitives
Aplica-se a
Add(UInt32, UInt32)
Adiciona dois números inteiros sem sinal de 32 bits e substitui o primeiro inteiro pela soma, como uma operação atômica.Adds two 32-bit unsigned integers and replaces the first integer with the sum, as an atomic operation.
public:
static System::UInt32 Add(System::UInt32 % location1, System::UInt32 value);
public static uint Add (ref uint location1, uint value);
static member Add : uint32 * uint32 -> uint32
Public Shared Function Add (ByRef location1 As UInteger, value As UInteger) As UInteger
Parâmetros
- location1
- UInt32
Uma variável que contém o primeiro valor a ser adicionado.A variable containing the first value to be added. A soma dos dois valores é armazenada em location1
.The sum of the two values is stored in location1
.
- value
- UInt32
O valor a ser adicionado ao inteiro em location1
.The value to be added to the integer at location1
.
Retornos
O novo valor armazenado em location1
.The new value stored at location1
.
Exceções
O endereço de location1
é um ponteiro null
.The address of location1
is a null
pointer.
Aplica-se a
Add(UInt64, UInt64)
Adiciona dois números inteiros sem sinal de 64 bits e substitui o primeiro inteiro pela soma, como uma operação atômica.Adds two 64-bit unsigned integers and replaces the first integer with the sum, as an atomic operation.
public:
static System::UInt64 Add(System::UInt64 % location1, System::UInt64 value);
public static ulong Add (ref ulong location1, ulong value);
static member Add : uint64 * uint64 -> uint64
Public Shared Function Add (ByRef location1 As ULong, value As ULong) As ULong
Parâmetros
- location1
- UInt64
Uma variável que contém o primeiro valor a ser adicionado.A variable containing the first value to be added. A soma dos dois valores é armazenada em location1
.The sum of the two values is stored in location1
.
- value
- UInt64
O valor a ser adicionado ao inteiro em location1
.The value to be added to the integer at location1
.
Retornos
O novo valor armazenado em location1
.The new value stored at location1
.
Exceções
O endereço de location1
é um ponteiro null
.The address of location1
is a null
pointer.