Sorry to post such basic questions, I’m new to LINQ and am trying to figure out the best way to do this short of looping through each IList.
I have 2 ILists<> with of custom dto objects. I want to remove all the matching items from on list that are in the other.
IList<ItemDTO> list1 = itemsbl.GetBestItems();
IList<ItemDTO> list2 = itemsbl.GetWorstItems();
I need to remove all the items in list1 from list2. I have been looking at the Except() method but apparently i need my ItemsDTO class to override the GetHashCode and Equals methods for that to work, but i am having trouble finding some examples of this.
Could someone please show me the best way to remove list1 from list2?
Thanks again
You can probably use the Except method to do this.
If you want to replace list2 then just do this:
From MSDN: