Skip to content

Instantly share code, notes, and snippets.

@dend
Created January 17, 2013 05:51
Show Gist options
  • Save dend/4553993 to your computer and use it in GitHub Desktop.
Save dend/4553993 to your computer and use it in GitHub Desktop.
Prism implementation of RemoveAll (Feb2012 release)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
public static void RemoveAll<T>(this List<T> list, Func<T, bool> filter)
{
if (list == null) throw new ArgumentNullException("list");
if (filter == null) throw new ArgumentNullException("filter");
for (int i = 0; i < list.Count; i++)
{
if (filter(list[i]))
{
list.Remove(list[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment