Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- var coll = new[] {1, 2, 4, 22, 23, 12};
- var result = coll.Filter(i => i > 13);
- }
- }
- static class Ext
- {
- public static IEnumerable<T> AsEnumerable<T> (this T item)
- {
- yield return item;
- }
- public static IEnumerable<T> Filter<T>(this IEnumerable<T> items, Predicate<T> predicate)
- {
- return items.Aggregate(Enumerable.Empty<T>(), (ints, arg) => predicate(arg) ? ints.Concat(arg.AsEnumerable()) : ints);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment