I have a list (List<T>) of objects aList and another list bList.
How to use Linq to delete all objects from aList contained in bList?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The simplest way would be to do this:
Removedoesn’t do anything if the item isn’t already in the list.If by “use LINQ” you mean use LINQ to determine if an item in
aListis inbList, that’s not necessary.A LINQ solution would be more efficient ONLY if both of these conditions are true:
aListis very small compared tobListaListthat are also inbListare at the very beginning ofbList