📅  最后修改于: 2022-03-11 14:48:32.043000             🧑  作者: Mango
public class ProductNumberEqualityComparer : IEqualityComparer
{
public int GetHashCode(Product obj)
{
return (obj == null) ? 0 : obj.ProductNumber.GetHashCode();
}
public bool Equals(Product x, Product y)
{
if (ReferenceEquals(x, y)) return true;
if (x == null || y == null) return false;
return x.ProductNumber == y.ProductNumber;
}
}