LIst去重,重写方法,继承接口。

调用: 
var dataThis = data.Where(es=>es.IndentyTime== identyDateList[0]).ToList(); var dic = dataThis.Distinct( new repDic()).ToList();var repList = ""; foreach (var item in dic) { if (repList == "") repList = item.RepID.ToString(); else repList += ","+item.RepID.ToString(); }
去重方法:     
public class repDic : IEqualityComparer<Ta_GoodsValue> { public bool Equals(Ta_GoodsValue x,Ta_GoodsValue y) { return x.RepID == y.RepID; } public int GetHashCode(Ta_GoodsValue x) { return x.ToString().GetHashCode(); } }
原文地址:https://www.cnblogs.com/axu92312/p/6206356.html