InterlockedCompareExchange Method (Int32, Int32, Int32) |
Compares two 32-bit signed integers for equality and, if they are equal, replaces one of the values.
Namespace: System.ThreadingAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static int CompareExchange(
ref int location1,
int value,
int comparand
)
Parameters
- location1
- Type: SystemInt32
The destination, whose value is compared with comparand and possibly replaced. - value
- Type: SystemInt32
The value that replaces the destination value if the comparison results in equality. - comparand
- Type: SystemInt32
The value that is compared to the value at location1.
Return Value
Type:
Int32The original value in
location1.
Exceptions Exception | Condition |
---|
NullReferenceException | The address of location1 is a null pointer. |
See Also