// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
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 source.Select(resultSelector).Concat();
}
}
}