System.Interactive.dll 包含一个For()
具有以下实现的方法:
IEnumerable<TResult> For<TSource, TResult>(
IEnumerable<TSource> source,
Func<TSource, IEnumerable<TResult>> resultSelector)
{
return source.Select<TSource, IEnumerable<TResult>>(resultSelector).Concat<TResult>();
}
我是否遗漏了某些东西,或者这是否等同于现有的Enumerable.SelectMany()
, 减号this
?
IEnumerable<TResult> SelectMany<TSource, TResult>(
this IEnumerable<TSource> source,
Func<TSource, IEnumerable<TResult>> selector)