Remove items from one list in another

Posted by coffeeaddict on Stack Overflow See other posts from Stack Overflow or by coffeeaddict
Published on 2010-04-30T15:14:14Z Indexed on 2010/04/30 15:17 UTC
Read the original article Hit count: 207

Filed under:

I'm trying to figure out how to traverse a generic list of items that I want to remove from another list of items.

So lest say I have this as a hypothetical example

List<car> list1 = GetTheList();
List<car> list2 = GetSomeOtherList();

I want to traverse list1 with a foreach and remove each item in List1 in List2.

I'm not quite sure how to go about that as foreach is not index based.

© Stack Overflow or respective owner

Related posts about c#