0

I would like to know if its possible to remove multiple items from list based on another list without create new list instance?

I know its possible to use the except method but it does not remove the elements from the original list like the removeAll does, I would have happy to use the removeAll but it does not have an overload for passing a list as parameter (only for Predicate).

Here are some references (1,2,3) similar to my question.

Shahar Shokrani
  • 7,598
  • 9
  • 48
  • 91
  • 3
    Possible duplicate of [Remove items from one list in another](https://stackoverflow.com/a/2745616/34092) - which shows a `RemoveAll` based solution. – mjwills Oct 25 '18 at 05:35
  • @pcdev Should I delete this question? actually the questions are bit different, although one of the answers is a truly duplicate. – Shahar Shokrani Oct 25 '18 at 05:56

1 Answers1

1

try this:

list1.RemoveAll(list => list2.Contains(list));
Anas Alweish
  • 2,818
  • 4
  • 30
  • 44