IEquatable<T> could have been declared to be contravariant in T, since it only uses T in an input position (or, equivalently, U being a subtype of T should imply that IEquatable<T> is [a subtype of] IEquatable<U>).
So, why did the BCL team not annotate it (for C# 4.0) with the ‘in’ keyword, as they did with many other generic interfaces (like the entirely analogous IComparable)?
I think this is mainly for a philosophical reason rather than a technical limitation–as it’s perfectly possible to simply annotate the interface.
IEquatable<T>is meant to compare objects of the same type for exact equality. An instance of a superclass is not usually considered equal to an instance of a subclass. Equality in this sense implies type equality too. This is a bit different fromIComparable<in T>. It can be sensible to define a relative sort order across different types.To quote MSDN page on
IEquatable<T>:This sentence further demonstrates the fact that
IEquatable<T>is meant to work between instances of a single concrete type.