Object.ReferenceEquals() Method in C# Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: csharp // C# program to demonstrate the // Object.ReferenceEquals(object) // Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // Declaring and initializing value1 object v1 = null; // Declaring and initializing value2 object v2 = null; // using ReferenceEquals(object, // object) method bool status = Object.ReferenceEquals(v1, v2); // checking the status if (status) Console.WriteLine("null is equal to null"); else Console.WriteLine("null is not equal to null"); } } Output:null is equal to null Example 2: csharp // C# program to demonstrate the // Object.ReferenceEquals(Object, Object) // Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { object p = new Object(); object q = null; // calling get() method get(p, null); // assigning p to q q = p; get(p, q); get(q, null); } // defining get() method public static void get(object v1, object v2) { // using ReferenceEquals(Object) method bool status = Object.ReferenceEquals(v1, v2); // checking the status if (status) Console.WriteLine("{0} is equal to {1}", v1, v2); else Console.WriteLine("{0} is not equal to {1}", v1, v2); } } Output: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: If both ob1 and ob2 represent the same instance of a value type, then this method nevertheless returns false.If ob1 and ob2 are strings, then this method will return true if the string is interned because this method will never perform a test for value equality. Reference: https://learn.microsoft.com/en-us/dotnet/api/system.object.referenceequals?view=netcore-2.1 Comment More infoAdvertise with us Next Article C# | Uri.Equals(Object) Method R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp Object Class Similar Reads Uri.ReferenceEquals() Method in C# with Examples Uri.ReferenceEquals() Method is used to check the reference of two specified objects. This method can be overridden and static in nature. So, if a user is going to test the two objects references for equality and he is not sure about the implementation of the Equals method, then he can call the Refe 2 min read C# | Uri.Equals(Object) Method Uri.Equals(Object) Method is used to compare two Uri instances for equality. Syntax: public override bool Equals (object comparand); Here, it takes the Uri instance or a URI identifier to compare with the current instance. Return Value: This method returns a Boolean value true if the two instances r 2 min read C# | Uri.Equals(Object) Method Uri.Equals(Object) Method is used to compare two Uri instances for equality. Syntax: public override bool Equals (object comparand); Here, it takes the Uri instance or a URI identifier to compare with the current instance. Return Value: This method returns a Boolean value true if the two instances r 2 min read C# | Byte.Equals(Object) Method This method is used to get a value which indicates whether the current instance is equal to a specified object or not. Syntax: public override bool Equals (object obj); Here, it takes an object to compare with the current instance or null. Return Value: This method returns true if obj is an instance 2 min read C# | Byte.Equals(Object) Method This method is used to get a value which indicates whether the current instance is equal to a specified object or not. Syntax: public override bool Equals (object obj); Here, it takes an object to compare with the current instance or null. Return Value: This method returns true if obj is an instance 2 min read LINQ | Equality Operator | SequenceEqual The equality operator is used to check whether the given two sequences are identically equal or not. In LINQ, the equality operation contains only one operator that is known as SequenceEqual. It is used to check whether the given elements in the sequence or collection are equal or not. If the given 3 min read Like