static IEnumerable <T> Filter <T>(IEnumerable <T> items , PredicateGenericDelegate <T> predicate) { var ret = new List <T>(); foreach (var item in items) { if (predicate(item)) { ret.Add(item); } } return(ret); }
//修改数据过滤方法 static IEnumerable <T> Filter <T>(IEnumerable <T> list, PredicateGenericDelegate <T> predicate) { //找出所有的偶数,放到List<int>集合中 var result = new List <T>(); foreach (var num in list) { if (predicate(num)) { result.Add(num); } } return(result); }