Created
April 18, 2019 08:54
-
-
Save ibnuh/b6555c2cdf068164344bd83617333b7f to your computer and use it in GitHub Desktop.
Conditional IEnumerable.Select
This file contains hidden or 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<TResult> SelectWhere<TSource, TResult>( | |
this IEnumerable<TSource> source, | |
Func<TSource, TResult> selector, | |
Func<TSource, bool> predicate) | |
{ | |
foreach (TSource item in source) | |
if (predicate(item)) | |
yield return selector(item); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment