CSharp examples for System.Collections.Generic:IEnumerable
The predicate returns false to stop the iteration.
using System.Reflection; using System.Linq; using System.Collections.Generic; using System;/* w w w . j av a2 s . c om*/ public class Main{ /// <summary> /// The predicate returns false to stop the iteration (and to indicate that it found the item). /// Iterate returns true once the predicate returned false the first time. /// </summary> public static bool Iterate<T>(this IEnumerable<T> items, Func<T, bool> predicate) { foreach (var item in items) { if (!predicate(item)) { return true; } } return false; } }