Filter IEnumerable with Predicate
using System; using System.Collections.Generic; using System.Collections; public static class CollectionUtils { public static IEnumerable<T> Filter<T>(IEnumerable<T> enumerable, Predicate<T> leave) { foreach (T elem in enumerable) if (leave(elem)) yield return elem; } }