CSharp examples for System.Collections.Generic:IList
Remove First from IList by condition
using System.Reflection; using System.Linq; using System.Collections.Generic; using System;/*from w w w . j ava2 s .c o m*/ public class Main{ public static T RemoveFirst<T>(this IList<T> items, Func<T, bool> filter) { for (var i = 0; i < items.Count; i++) { var item = items[i]; if (filter(item)) { items.RemoveAt(i); return item; } } return default(T); } }