![]() |
VOOZH | about |
Object.ReferenceEquals() Method is used to determine whether the specified Object instances are the same instance or not. This method cannot be overridden. So, if a user is going to test the two objects references for equality and is not sure about the implementation of the Equals method, then he can call the ReferenceEquals method.
Syntax: public static bool ReferenceEquals (object ob1, object ob2);
Parameters:
ob1: It is the first object to compare.
ob2: It is the second object to compare.
Return Value: This method returns true if ob1 is the same instance as ob2 or if both are null otherwise, it returns false.
Below programs illustrate the use of Object.ReferenceEquals() Method:
Example 1:
null is equal to null
Example 2:
System.Object is not equal to System.Object is equal to System.Object System.Object is not equal to
Note: Here, null will never be printed in the output. Important Points:
Reference: