c# - Most reliable way to clean List<T> depending on Predicate<T> -


i have list<t> data , predicate<t> condition.

what way should use clear data depending on condition result?

  • option 1:

    var del = data.where(i => condition); data.removeall(i => del.contains(i)); 
  • option 2:

    var del = data.where(i => condition); (int = 0; < del.count; i++)     data.remove(del[i]); 
  • option 3:

    var del = data.where(i => condition); foreach (var in del)    data.remove(i); 
  • option 4:

    data = data.where(i => !condition); 
  • any other?

how about:

data.removeall(condition); 

note fourth option won't work without call tolist().


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -