| InterlockedCompareExchange Method (IntPtr, IntPtr, IntPtr) | 
Compares two platform-specific handles or pointers for equality and, if they are equal, replaces one of them.
 
Namespace: System.ThreadingAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
 Syntax
Syntaxpublic static IntPtr CompareExchange(
	ref IntPtr location1,
	IntPtr value,
	IntPtr comparand
)
Parameters
- location1
- Type: SystemIntPtr
 The destination IntPtr, whose value is compared with the value of comparand and possibly replaced by value.
- value
- Type: SystemIntPtr
 The IntPtr that replaces the destination value if the comparison results in equality.
- comparand
- Type: SystemIntPtr
 The IntPtr that is compared to the value at location1.
Return Value
Type: 
IntPtrThe original value in 
location1.
 Exceptions
Exceptions| Exception | Condition | 
|---|
| NullReferenceException | The address of location1 is a null pointer. | 
 See Also
See Also