Possible Duplicate:
C# difference between==and .Equals()
For comparing two variables we can use == or Equals method. for example,
string a = new string(new char[] {'a', 'b', 'c', 'd'}); string b = new string(new char[] {'a', 'b', 'c', 'd'}); Console.WriteLine (a==b); Console.WriteLine (a.Equals(b)); My question is When should I use == and when should I use Equals? Is there any difference between the two?
==inconsistencies. Better use anyTypeHere.Equals, or object.Equals ienablemuch.com/2011/08/…