Equality for Different Types
Equality checks are of particular interest. For reference types, the default behavior of
!= is to check equality and inequality of the references. In other words, do both the left and right sides of the operator refer to the same object in memory? Often this behavior is not desirable, and operator overloading is used to redefine the meaning of equality, typically based on the underlying data contained by the type. A good example is
== checks that both strings have the same length and contain the same characters.
In the context of reference types and nullable value types, the equality checks against the null literal should also be considered. For reference types, this is based on checking ...