C#处理List<object>重复数据的问题


private class ListDistinct : IEqualityComparer<object>
{
            public bool Equals(object x, object y)
            {
                return x.ProductUniqueID == y.ProductUniqueID;//重复数据以...为准
            }

            public int GetHashCode(object obj)
            {
                return obj.ToString().GetHashCode();
            }
}

IEnumreable.Distinct(new ListDistinct()).ToList();//过滤掉集合对象的重复数据

posted @ 2018-09-07 15:11  CH|heyi  阅读(904)  评论(0编辑  收藏  举报