How to Remove multiple items in List using RemoveAll on condition?

I tried like following.

MyList.RemoveAll(t => t.Name == "ABS");
MyList.RemoveAll(t => t.Name == "XYZ");
MyList.RemoveAll(t => t.Name == "APO");

Instead how can I do something like:

MyList.RemoveAll(t => t.Name == "ABS" || t => t.Name == "XYZ" ||t => t.Name == "APO");
Jon Skeet
people
quotationmark

You only need one lambda expression - the || goes within that:

MyList.RemoveAll(t => t.Name == "ABS" || t.Name == "XYZ" || t.Name == "APO");

In other words, "Given a t, I want to remove the element if t.Name is ABS, or if t.Name is XYZ, or if t.Name is APO."

There's only one "given a t" in there, which is what the t => part means, effectively.

people

See more on this question at Stackoverflow