Created
January 19, 2014 08:31
-
-
Save onozaty/8501987 to your computer and use it in GitHub Desktop.
System/Linq/Enumerable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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