SelectMany.cs 1.7 KB

123456789101112131415161718192021222324252627282930
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Collections.Generic;
  5. namespace System.Linq
  6. {
  7. public static partial class AsyncEnumerableEx
  8. {
  9. /// <summary>
  10. /// Projects each element of the source async-enumerable sequence to the other async-enumerable sequence and merges the resulting async-enumerable sequences into one async-enumerable sequence.
  11. /// </summary>
  12. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13. /// <typeparam name="TOther">The type of the elements in the other sequence and the elements in the result sequence.</typeparam>
  14. /// <param name="source">An async-enumerable sequence of elements to project.</param>
  15. /// <param name="other">An async-enumerable sequence to project each element from the source sequence onto.</param>
  16. /// <returns>An async-enumerable sequence whose elements are the result of projecting each source element onto the other sequence and merging all the resulting sequences together.</returns>
  17. /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="other"/> is null.</exception>
  18. public static IAsyncEnumerable<TOther> SelectMany<TSource, TOther>(this IAsyncEnumerable<TSource> source, IAsyncEnumerable<TOther> other)
  19. {
  20. if (source == null)
  21. throw Error.ArgumentNull(nameof(source));
  22. if (other == null)
  23. throw Error.ArgumentNull(nameof(other));
  24. return source.SelectMany(_ => other);
  25. }
  26. }
  27. }