I have two collections (shared lists), call them ListA and ListB.
In ListA, I have several elements of type A. In ListB, I have some elements of type B that have an ID (but not the same type) as the elements in ListA, and many more. I want to remove all elements from listB that have the same identifier as in ListA. What is the best way to do this? Are Linq objects in good shape? Which algorithm would you use?
Example
ListA: ItemWithID1, ItemWithID2¨
ListB: ItemWithID1, ItemWithID2, ItemWithID3, ItemWithID4
EDIT: I forgot to mention in my original question that ListA and ListB do not contain the same types. Thus, the only way to compare them is through the .Id property. This invalidates the answers I have received so far.
source
share