标签:
//原数据
List<T_Model> tmpListAll=new List<T_Model>();
//去除集合中重复数据后
List<T_Model> tmpList = tmpListAll.Distinct(new AutoFilterParmsCompare()).ToList();
/// <summary>
/// 比较器
/// </summary>
public class AutoFilterParmsCompare : EqualityComparer<T_Model>
{
public override bool Equals(T_Model x,T_Model y)
{
return x.InvoiceNo == y.InvoiceNo && x.InvoiceDate == y.InvoiceDate;
}
public override int GetHashCode(OutputVATModels.Tmp_InputVatInvoice obj)
{
return obj.InvoiceNo.GetHashCode();
}
}
public class T_Model{
public string InvoiceNo{get;set;}
public string InvoiceDate {get;set;}
}
标签:
原文地址:http://www.cnblogs.com/Harvard-L/p/5434710.html