Skip to content

Instantly share code, notes, and snippets.

@dvdme
Last active December 12, 2022 07:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvdme/6498e8737159f43874a1b0d441eb70ac to your computer and use it in GitHub Desktop.
Save dvdme/6498e8737159f43874a1b0d441eb70ac to your computer and use it in GitHub Desktop.
C# List of lists Flattener
public static class ListExtension
{
/// <summary>
/// Creates a single flat list from a list of lists input.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="inListOfLists"></param>
/// <returns>A single flatten list from a list of lists input</returns>
public static List<T> Flatten<T>(this List<List<T>> inListOfLists)
{
List<T> outList = new List<T>();
foreach (var list in inListOfLists)
{
outList.AddRange(list);
}
return outList;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment