Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
4 Points
3 Posts
Jan 11, 2010 12:16 PM|LINK
a==b is used to compare references where as a.Equals(b) is used to compare the values they are having. For Ex: public class Class1 { string name = String.Empty; public Class1(string strName) { strName = name; } } Class1 a = new Class1("Hello"); Class1 b = new Class1("Hello"); a==b // Returns false a.Equals(b) // Returns true
asp.net developers india
monalisa_pra...
Member
4 Points
3 Posts
Re: What is the difference between a.Equals(b) and a == b?
Jan 11, 2010 12:16 PM|LINK
a==b is used to compare references where as a.Equals(b) is used to compare the values they are having.
For Ex:
public class Class1
{
string name = String.Empty;
public Class1(string strName)
{
strName = name;
}
}
Class1 a = new Class1("Hello");
Class1 b = new Class1("Hello");
a==b // Returns false
a.Equals(b) // Returns true
asp.net developers india
Monalisa
Mindfire: India's Only Company to be both Apple Premier & Microsoft Gold certified.