CSharp examples for System.Collections:ICollection
Remove from ICollection by condition
// of the GNU Public License, verison 2. using System.Text; using System.Linq; using System.Collections.Generic; using System;//from w ww . j a v a 2 s. co m public class Main{ public static void RemoveIf<T>(this ICollection<T> collection, Func<T, bool> predicate) { var elements = collection.Where(predicate).ToList(); foreach(var element in elements) collection.Remove(element); } }