Adding to the answers posted here, I think we should also be able to specify if you we want value or reference equality:
static public class MyGenericHelper
{
static public bool EqualsByValue(T x, T y)
{
return EqualityComparer.Default.Equals(x, y);
}
static public bool EqualsByReference(T x, T y)
{
if (x is ValueType) return EqualityComparer.Default.Equals(x, y) // avoids boxing
return Object.ReferenceEquals(x, y);
}
}
We all just love to create and maintain a zillion little helper methods like that don't we :->