Determines whether two Object instances are equal.
string
string s2 = "Hello";
Console.WriteLine(s1.Equals(s2)); // this returns true since both s1 and s2 contain the string 'Hello'
Console.WriteLine(Object.ReferenceEquals(s1, s2)); // this also returns true!!Here the Object.ReferenceEquals returns true since although s1 and s2 are two different string objects; .NET CLR handles strings in a special way and according to my understanding uses string pooling wherein two strings that have the same content will point to the same memory location.Let me know if there is any misunderstanding on my side with respect to the above statement
If you override Equals to check for value equality, you can still check for reference equality on your objects by using the ReferenceEquals method.
Another implication of this is that you should not depend on the Equals method to check for reference equality - use ReferenceEquals instead since Equals may have been overridden to test value equality.
{
if ( object.ReferenceEquals( a, b ) )
return true;
return a.Equals( b );
}
check this article . says opposite http://msdn.microsoft.com/en-us/library/ms173147(VS.80).aspxIt says a==b is for Reference equal and a.equals(b) is for Value equal