// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace System.Linq { public static partial class EnumerableEx { /// /// Generates a sequence by enumerating a source sequence, mapping its elements on result sequences, and concatenating /// those sequences. /// /// Source sequence element type. /// Result sequence element type. /// Source sequence. /// Result selector to evaluate for each iteration over the source. /// /// Sequence concatenating the inner sequences that result from evaluating the result selector on elements from /// the source. /// public static IEnumerable For(IEnumerable source, Func> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); return ForCore(source, resultSelector) .Concat(); } private static IEnumerable> ForCore(IEnumerable source, Func> resultSelector) { return source.Select(resultSelector); } } }