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(); } }

 

posted @ 2016-12-21 09:22  阿旭92312  阅读(306)  评论(0编辑  收藏  举报