I have two lists, one containing urls and another, containing all MIME file extensions. I want to remove from the first list all urls that point to such files.
Sampl
If you want to create a new list with only the items matching your condition:
List<string> result = urls.Where(x => !mime.Any(y => x.EndsWith(y))).ToList();
If you want to actually remove items from source, you should use RemoveAll
:
urls.RemoveAll(x => mime.Any(y => x.EndsWith(y)));
here is a one liner that fits your needs
urls.RemoveAll(x => mime.Any(y => x.EndsWith(y)));
maybe this is a safer appraoach
urls.RemoveAll(x => mime.Contains(Path.GetExtension(x)));
When you have URLs like http://stackoverflow.com/questions/dir/some.ashx?ID=.pdf
you should think about another approach