TrueForOne
This page is open to edits. Please leave the original in tact and add your own version or corrections at the bottom. --chuck
internal static class ListUtil
{
/// <summary>
/// returns true if at least one item in the collection meets passes the 'critera'
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="coll"></param>
/// <param name="criteria"></param>
/// <returns></returns>
public static bool TrueForOne<T>(this System.Collections.Generic.List<T> coll, Func<T, bool> criteria)
{
if (coll == null) return false;
foreach (T t in coll)
{
if (criteria(t))
{
return true;
}
}
return false;
}
}