<p>I've got two collections (generic Lists), let's call them ListA and ListB.</p>

<p>In ListA I've got a few items of type A. In ListB I've got some items of type B that have the SAME ID (but not same type) as the items in ListA, plus many more. I want to remove all the items from ListB that have the same ID as the ones in ListA. What's the best way of doing this? Is Linq to objects a nice fit? What algorithm would you use?</p>

<p>Example</p>

<p>ListA: ItemWithID1, ItemWithID2¨</p>

<p>ListB: ItemWithID1, ItemWithID2, ItemWithID3, ItemWithID4</p>

<p>EDIT: I forgot to mention in my original question that ListA and ListB doesn't contain the same types. So the only way to compare them is through the .Id property. Which invalidates the answers I've gotten so far.</p>

simple loop:
```
```
for (item i: LISTA) {
    removeItem(i, LISTB);
}

method removeItem(Item, List) {
    for (Item i: List) {
        if (Item == i)
            List.removeItem(i);
    }
}
```
```