CSharp examples for System.Collections.Generic:IEnumerable
Find All Element from IEnumerable by Predicate
using System.Collections.Generic; using System.Collections; using System;//from w ww. j ava 2 s. c o m public class Main{ /// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection"></param> /// <param name="p"></param> /// <returns></returns> public static List<T> FindAll<T>(IEnumerable<T> collection, Predicate<T> p) { List<T> ret = new List<T>(); foreach (T obj in collection) { if (p(obj)) ret.Add(obj); } return ret; } }