list 去重方法之一

List<SupplierBase> yuanList = new List<SupplierBase>();
yuanList = ShareDal.GetCompanyListByTagId(tagId);
CompanyList = new List<SupplierBase>();

Hashtable hash = new Hashtable();

foreach (var item in yuanList)//源LIST去重
{
if (!hash.ContainsKey(item.CompanyID))
{
hash.Add(item.CompanyID, item);
CompanyList.Add(item);//把不重复的列加入
}
}

posted @ 2020-12-07 15:30  Focus and Learn  阅读(68)  评论(0编辑  收藏  举报