Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IEnumberable<Car> list
- list.RemoveWhere(r=>r.Year > 2000)
- list = list.Where(r=>r.Year<=2000)
- public static IEnumerable<T> RemoveWhere<T>(this IEnumerable<T> query, Predicate<T> predicate)
- {
- return query.Where(e => !predicate(e));
- }
- MyList.RemoveAll( p => p.MyProperty == MyValue );
- list = list.Where(car => car.Year <= 2000);
- public static class CollectionExtensions {
- public static ICollection<T> RemoveWhere<T>(this ICollection<T> collection, Func<T, bool> predicate) {
- List<T> toRemove = collection.Where(item => predicate(item)).ToList();
- toRemove.ForEach(item => collection.Remove(item));
- return collection;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement