What do you think of my own implementation of the extension method SelectMany
?
Motivating criticism is always welcome.
public static IEnumerable<TResult> MySelectMany<T, TResult>(this IEnumerable<T> source, Func<T, IEnumerable<TResult>> selector)
{
var theList = new List<TResult>();
foreach (T item in source)
{
foreach (TResult inneritem in selector(item))
{
theList.Add(inneritem);
}
}
return theList as IEnumerable<TResult>;
}
SelectMany()
. \$\endgroup\$