1. ReferenceEquals and Equals methods behaves same for Reference types but it differs for value types.
2.ReferenceEquals is a Static method and hence we cannot override this method where as Equals method we can override this method.
Ex1:
bool b=0.Equals(0);
bool b1=Object.ReferenceEquals(0, 0);
Response.Write(b);
Ex2:
//Write this code in the main method.
Palle p1 = new Palle(2);
Palle p2 = new Palle(2);
bool b1=p1.Equals(p1);
bool b2=object.ReferenceEquals(p1, p2);
//Both b1 & b2 will be false here
public class Palle
{
public int age;
public Palle(int age)
{
this.age = age;
}
}


Latest Comments