using System; using System.Linq; using System.Collections.Generic; namespace Flowchart { static class CollectionHelper { public static void RemoveRange(this ICollection source, Func predicate) { var arr = source.Where(p => predicate(p)).ToArray(); foreach (var t in arr) { source.Remove(t); } } } }