Skip to content

Instantly share code, notes, and snippets.

@ferventcoder
Created September 24, 2012 22:29
Show Gist options
  • Save ferventcoder/3778846 to your computer and use it in GitHub Desktop.
Save ferventcoder/3778846 to your computer and use it in GitHub Desktop.
How to Remove Items from A List ?
foreach (var item in items.ToList())
{
items.Remove(item);
}
@vongillern
Copy link

as we discussed on twitter, this has potential worst case runtime of O(n*m) = O(n^2) instead of the pastie that has a worst case runtime of O(2n) = O(n) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment