Flats the specified list of list. - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IList

Description

Flats the specified list of list.

Demo Code


using System.Collections.Generic;
using System.Collections;
using System;//ww w .  ja v  a2s.c om

public class Main{
        /// <summary>
        /// Flats the specified groups.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="groups">The groups.</param>
        /// <returns></returns>
        public static List<T> Flat<T>(List<List<T>> groups)
        {
            List<T> items = new List<T>();
            foreach (List<T> group in groups)
            {
                items.AddRange(group);
            }
            return items;
        }
}

Related Tutorials