
object.Equals compares the contents of objects. It first checks to see if the references are equal, as does object.ReferenceEquals. But then it calls into derived Equals methods to test equality further.
This C# example program uses the object.Equals method. It shows object.ReferenceEquals.

This program uses strings as the arguments to object.Equals. It uses two strings: one is a string literal, and a second is a character that is converted to a string with ToString. The string literal "a" and the result of ToString() are in different memory locations; their references are thus not equal. However, object.Equals checks their contents and finds them to be equal.
String Literal ToStringProgram that uses object.Equals method [C#]
using System;
class Program
{
static void Main()
{
// object.Equals compares the contents of two objects.
// ... They can be in separate memory locations and be equal.
bool b = object.Equals("a", 'a'.ToString());
Console.WriteLine(b);
// object.ReferenceEquals compares the references of two objects.
// ... They can only be equal if they are in the same memory location.
b = object.ReferenceEquals("a", 'a'.ToString());
Console.WriteLine(b);
}
}
Output
True
False
What about object.ReferenceEquals? With object.ReferenceEquals, the two strings with equal data are determined to have different references. This is because they are in different memory locations. References are a simple value that indicates a memory location.
object.ReferenceEquals Method
The object.Equals method internally compares the two formal parameters for referential equality. Conceptually, it itself calls object.ReferenceEquals. Thus, object.Equals is the same as object.ReferenceEquals except it additionally calls a virtual Equals method on the two objects.
The object.Equals and object.ReferenceEquals method have an important difference in the C# language. Equals actually checks the contents of the objects; ReferenceEquals does not. Essentially, you will only want to use object.ReferenceEquals if you want to know if the two variables are the exact same object in the same memory location.
Object Class