C# - LINQ Extension: SelectMany without parameters

By , 10/1/2015
(0 ratings)
This extension method returns all items from the provided sub-lists like the already existing SelectMany methods.

But my method take no parameters so it can be a bit shorte than the .NET overloads.
namespace System.Linq
{
    using System.Collections.Generic;

    /// <summary>
    /// Contains extension methods to select all items from sub lists.
    /// </summary>
    public static class LINQ_SelectMany
    {
        /// <summary>
        /// Returns a collection with all items from the provided sub-lists.
        /// </summary>
        /// <typeparam name="T">The type of the items in sub-lists.</typeparam>
        /// <param name="source">The list of sub-lists.</param>
        /// <returns>A collection of all items from <paramref name="source"/>.</returns>
        public static IEnumerable<T> SelectMany<T>(this IEnumerable<IEnumerable<T>> source)
        {
            return source.SelectMany(x => x);
        }
    }
}

Tagged with LINQ, SelectMany, Extension.

Comments

 

Log in, to comment!