Equals(T x, T y)
关于 IEqualityComparer,除了我下面的内容之外,是否有任何理由说明实现应该是什么?
public class MyEquality : IEqualityComparer<MyType>
{
//My Equals(T x, T y) always looks like this
public bool Equals(MyType x, MyType y)
{
return this.GetHashCode(x).Equals(this.GetHashCode(y));
}
public int GetHashCode(MyType obj)
{
//assume MyType has a non-nullable member called ID
return obj.ID.GetHashCode();
}
}