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(); }
时间: 2024-12-28 08:42:19