Object base class has the following code which compares equality of two objects
public static bool Equals(Object objA, Object objB)
{
if (objA==objB) {
return true;
}
if (objA==null || objB==null) {
return false;
}
return objA.Equals(objB);
}
What is the difference between comparisons objA==objB and objA.Equals(objB) and why do we need to check objA==objB separately?
UPDATE: The comment in the source code says that "Equality is defined as object equality for reference types and bitwise equality for value types". Thus if we deal with reference type and objA!=objB then we must return false without other comparisons, don't we? objA.Equals(objB) looks redundant here.