Skip to content

Instantly share code, notes, and snippets.

@hatelove
Last active December 19, 2015 09:19
Show Gist options
  • Save hatelove/5932379 to your computer and use it in GitHub Desktop.
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 ) 的基本架構
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