Suppose I have a collection of strings.
How do I select all the elements that don’t contain a certain parameter value?
List<string> TheList = .....
var TheCleanList = (from s in TheList
where s != parameter
select s).ToList();
I was thinking about where s!= parameter but I’m wondering if there’s a cleaner way to do it.
Thanks.
If you don’t need a new list you don’t need Linq for this – use
Remove()– this avoids having to create a new list:If you want to remove all strings that are equal to
Parameter:If you want to remove all strings that contain
Parameter(not clear from your question):