Suppose I have two list of T
, I need to remove from list A
all the elements that are not in list B
. I did this:
A.RemoveAll(item => !B.Contains(item));
this working pretty well, but if the list B
does not contains any elements, this code will remove all the items from the list A
and it shouldn't. Why happen that?