What is the difference between "==" and "object.EqualsTo"
"==" Vs "Object.EqualsTo"
'==' only compares the value where as 'object.equalsto' compares the both value as well as type
Both are used for comparison and both returns the boolean value (true/false)
Case 1. In case a and b both are different datatype then also a.Equals(b) can be used to compare but incase of == we cant even compile the code if a and b are different data type
Example1 for "==" Vs "Object.EqualsTo":
//above code will compile successfully and internally the int b will convert to object type and compare
//above code will give you the compilation error
Case 2. by using == we cant compare two object but Equals method will able to compare both the object internally
Example 2 for "==" Vs "Object.EqualsTo":
a==b is used to compare references where as a.Equals(b) is used to compare the values they are having.
colour = str;
Mycar a = new Mycar("blue");
Mycar b = new Mycar("blue");
a==b // Returns false
a.Equals(b) // Returns true