Click or drag to resize
InterlockedCompareExchange Method (Object, Object, Object)
Compares two objects for reference equality and, if they are equal, replaces one of the objects.

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static Object CompareExchange(
	ref Object location1,
	Object value,
	Object comparand
)

Parameters

location1
Type: SystemObject
The destination object that is compared with comparand and possibly replaced.
value
Type: SystemObject
The object that replaces the destination object if the comparison results in equality.
comparand
Type: SystemObject
The object that is compared to the object at location1.

Return Value

Type: Object
The original value in location1.
Exceptions
ExceptionCondition
ArgumentNullExceptionThe address of location1 is a null pointer.
See Also