Implementing (IComparable<T>), IEquatable<T> and the equality members

IComparable<T>, IEquantable<T>, IHaveTheSolution

Reading through the web I hit upon two blog posts (Classes implementing IComparable<T> and null (German) and the following post Classes implementing IComparable<T> and null the second (German)). In the first one there was a discussion about how to implement the “equality members” (Equals, IEquatable<T> and the equality operators).

One problem was, that overriding the equality operator (==) so that it calls Equals makes an implementation of Equals as follows impossible (lets say our class is called Foo):

Read the rest of this entry »