That would possibly work if it knew that where T : class
, doing a reference comparison. Operators generally have very little support with generics, but there are workarounds. MiscUtil offers indirect support for operators on generics, otherwise EqualityComparer.Default.Equals(x,y)
is a good choice.