CSharp examples for System.Collections.Generic:IList
Remove element from IList
using System.Collections; using System.Text; using System.Linq; using System.Collections.Generic; using System;/*from ww w .j a v a 2 s .c om*/ public class Main{ public static void Remove<T>(this IList<T> source, Func<T, bool> condition) { if (source == null) return; IList<T> lst = source.Yield(p => p, condition); foreach (T tmpT in lst) { source.Remove(tmpT); } } public static IList<R> Yield<Key, Value, R>(this IDictionary<Key, Value> source, Func<KeyValuePair<Key, Value>, R> func) { if (source == null) { return new List<R>(); } IList<R> lstR = new List<R>(); foreach (var item in source) { lstR.Add(func(item)); } return lstR; } public static IList<R> Yield<T, R>(this IEnumerable<T> source, Func<T, R> func, Func<T, bool> condition) { if (source == null) { return new List<R>(); } IList<R> lstR = new List<R>(); foreach (var item in source) { if (condition(item)) { lstR.Add(func(item)); } } return lstR; } public static IList<R> Yield<T, R>(this IEnumerable<T> source, Func<T, R> func) { if (source == null) { return new List<R>(); } IList<R> lstR = new List<R>(); foreach (var item in source) { lstR.Add(func(item)); } return lstR; } }