Create an equality comparer for the type, then you can use that to efficiently compare the sets: public class MyFileComparer : IEqualityComparer { public bool Equals(MyFile a, MyFile b) { return a. CompareName == b. CompareName && a.
Size == b. Size && a. DateCreated == b.
DateCreated; } public int GetHashCode(MyFile a) { return (a.compareName.GetHashCode() * 251 + a.size.GetHashCode()) * 251 + a.dateCreated.GetHashCode(); } } Now you can use this with methods like Intersect to get all items that exist in both lists, or Except to get all items that exist in one list but not the other: List tempList = s.lstFiles. Intersect(d. LstFiles, new MyFileComparer()).ToList() As the methods can use the hash code to divide the items into buckets, there are a lot less comparisons that needs to be done compared to a join where it has to compare all items in one list to all items in the other list.
Create an equality comparer for the type, then you can use that to efficiently compare the sets: public class MyFileComparer : IEqualityComparer { public bool Equals(MyFile a, MyFile b) { return a. CompareName == b. CompareName && a.
Size == b. Size && a. DateCreated == b.
DateCreated; } public int GetHashCode(MyFile a) { return (a.compareName.GetHashCode() * 251 + a.size.GetHashCode()) * 251 + a.dateCreated.GetHashCode(); } } Now you can use this with methods like Intersect to get all items that exist in both lists, or Except to get all items that exist in one list but not the other: List tempList = s.lstFiles. Intersect(d. LstFiles, new MyFileComparer()).ToList(); As the methods can use the hash code to divide the items into buckets, there are a lot less comparisons that needs to be done compared to a join where it has to compare all items in one list to all items in the other list.
LINQ has an Except() method for this purpose. You can just use a. Except(b).
Use Except() and read more about set operations with linq and set operations with HashSet.
I need to compare two lists where each list contains about 60,000 objects. What would be the most efficient way of doing this? I want to select all the items that are in the source list that do not exist in the destination list.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.