How to convert List<List<int>> to an array of arrays
int[][] arrays = lst.Select(a => a.ToArray()).ToArray();
It's easy with LINQ:
lst.Select(l => l.ToArray()).ToArray()
If you really wanted two-dimentional array (int[,]
, not int[][]
), that would be more difficult and the best solution would probably be using nested for
s.
you can easily do it using linq.
int[][] arrays = lst.Select(a => a.ToArray()).ToArray();
but if you want another way you can loop through the list and manually generate the 2d array.
how to loop through nested list