Mono Class Library: System.Object Overview | Members

System.Object.ReferenceEquals Method

Determines whether two object references are identical.

[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)]
public static bool ReferenceEquals (object objA, object objB)

Parameters

objA
Documentation for this section has not yet been entered.
objB
Documentation for this section has not yet been entered.

Returns

True if a and b refer to the same object or are both null references; otherwise, false.

Remarks

This static method provides a way to compare two objects for reference equality. It does not call any user-defined code, including overrides of object.Equals(object) .

Example

C# Example

using System;
class MyClass {
   static void Main() {
   object o = null;
   object p = null;
   object q = new Object();
   Console.WriteLine(Object.ReferenceEquals(o, p));
   p = q;
   Console.WriteLine(Object.ReferenceEquals(p, q));
   Console.WriteLine(Object.ReferenceEquals(o, p));
   }
}
   

The output is

True
True
False

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0