.net 比较器

internal class DistinctComparer : IEqualityComparer<sy_phone>
    {
        public bool Equals(sy_phone x, sy_phone y)
        {
            return x.Phone == y.Phone;
        }

        public int GetHashCode(sy_phone obj)
        {
            return $"{obj.Phone}".GetHashCode();
        }
    }

 调用

listPhone.Distinct(new DistinctComparer()).ToList()

 

上一篇:白银莲花池


下一篇:视图维护