1

I have a List with 100k elements. I want to remove all elements from list that contain one of the strings from another List. I use RemoveAll which is quite slow, so wondering if there is a better solution.

public static void RemoveElements(List<string> input, List<string> items)
{
   foreach(var item in items)
   {
       input.RemoveAll(x => x.Contains(item));
   }
}
Nenad Birešev
  • 377
  • 2
  • 10
  • 1
    RemoveAll is already fastest option, so the only thing you can do is to not call it multiple times with "string contains in array" check as shown in duplicate. – Alexei Levenkov Jan 13 '20 at 03:54

0 Answers0