Last active
December 19, 2015 09:19
-
-
Save hatelove/5932379 to your computer and use it in GitHub Desktop.
public static IEnumerable<TResult> SelectManay<TSource, TCollection, TResult>(this IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector )
的基本架構
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> SelectManay<TSource, TCollection, TResult>(this IEnumerable<TSource> source, | |
Func<TSource, int, IEnumerable<TCollection>> collectionSelector, | |
Func<TSource, TCollection, TResult> resultSelector | |
) | |
{ | |
var index = 0; | |
foreach (TSource sourceItem in source) | |
{ | |
IEnumerable<TCollection> collection = collectionSelector(sourceItem, index); | |
foreach (TCollection collecitonItem in collection) | |
{ | |
TResult result = resultSelector(sourceItem, collecitonItem); | |
yield return result; | |
} | |
index++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment