CSharp examples for System.Collections:IEnumerable
Exists in IEnumerable by Predicate
using System.Collections.Generic; using System.Collections; using System;/*w ww . j a va2s. co m*/ public class Main{ internal static bool Exists<T>(IEnumerable<T> collection, Predicate<T> predicate) { if (collection == null) throw new ArgumentNullException("collection"); if (predicate == null) throw new ArgumentNullException("predicate"); foreach (T item in collection) { if (predicate(item)) return true; } return false; } }