Last active
December 12, 2022 07:09
-
-
Save dvdme/6498e8737159f43874a1b0d441eb70ac to your computer and use it in GitHub Desktop.
C# List of lists Flattener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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