标签:
List元素类:
public class MultiPointSearchingRet { public int ID { get; set; } public string PlateNumber { get; set; } public int VehicleBrand1 { get; set; } public string BrandName { get; set; } }
实现了IEqualityComparer的比较类:
public class MultiPointSearchingRetComparer : IEqualityComparer<MultiPointSearchingRet> { public bool Equals(MultiPointSearchingRet x, MultiPointSearchingRet y) { return x.PlateNumber == y.PlateNumber && x.VehicleBrand1 == y.VehicleBrand1; } public int GetHashCode(MultiPointSearchingRet obj) { return obj.ID.GetHashCode(); } }
调用:
List<MultiPointSearchingRet>[] tmpLst = new List<MultiPointSearchingRet>[10]; List<MultiPointSearchingRet> retLst = new List<MultiPointSearchingRet>(); //略 for (int i = 0; i < length; i++) { if (i == 0) retLst = tmpLst[i]; else retLst = retLst.Intersect(tmpLst[i], new MultiPointSearchingRetComparer()).ToList(); }
标签:
原文地址:http://www.cnblogs.com/zhengwk/p/5264767.html