Skip to content

Instantly share code, notes, and snippets.

@onozaty
Created January 19, 2014 08:31
Show Gist options
  • Save onozaty/8501987 to your computer and use it in GitHub Desktop.
Save onozaty/8501987 to your computer and use it in GitHub Desktop.
System/Linq/Enumerable.cs
public static bool Any<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) {
if (source == null) throw Error.ArgumentNull("source");
if (predicate == null) throw Error.ArgumentNull("predicate");
foreach (TSource element in source) {
if (predicate(element)) return true;
}
return false;
}
public static bool All<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) {
if (source == null) throw Error.ArgumentNull("source");
if (predicate == null) throw Error.ArgumentNull("predicate");
foreach (TSource element in source) {
if (!predicate(element)) return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment