Search This Blog

Monday, February 11, 2013

what is difference between equals() and == operator

Both are used for comparison and boll returns the boolean value (true/false)

but in case a and b both are different datatype then also a.Equals(b) can be used to compare
but incase of == we cant event compaile the code if a and b are different data type

Example :
int a=0;
string b="o";

//do some thing

//above code will compile successfully and internally the int b will convert to object type and compare

//do some thing
//above code will give you the compilation error

2. by using == we cant compare two object
but Equals method will able to compare both the object internally

No comments:

Post a Comment