Created
July 20, 2017 14:16
-
-
Save christiannagel/0fc0d37d72b47f6fbb70543d17aef0c9 to your computer and use it in GitHub Desktop.
Where with earlier error information using a separate method
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 IEnumerable<T> Where<T>(this IEnumerable<T> source, Func<T, bool> predicate) | |
{ | |
if (source == null) throw new ArgumentNullException(nameof(source)); | |
if (predicate == null) throw new ArgumentNullException(nameof(predicate)); | |
return WhereImpl(source, predicate); | |
} | |
private static IEnumerable<T> WhereImpl<T>(IEnumerable<T> source, Func<T, bool> predicate) | |
{ | |
foreach (T item in source) | |
{ | |
if (predicate(item)) | |
{ | |
yield return item; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment