This post will discuss how to convert a List of Lists to a 2D array in C#.

You can use LINQ to convert a List<List<T>> into a two-dimensional array T[][]. The following code example uses the Select() method to project each list into an array with the help of the ToArray() method.

Download  Run Code

Output:

C, C++
Java, C#, Kotlin

 
If you need a T[,] instead, the best solution would probably be to loop through the list using nested loops and explicitly generate the 2D array.

Download  Run Code

Output:

C
C++
Java
Kotlin

That’s all about converting a List of Lists to a 2D array in C#.