Alex Rivera | Logout

How to convert List<List<int>> to an array of arrays

Asked 2011-06-04T17:37:42.080
39

What is the best way to convert a list into an array of type int[][]?

List<List<int>> lst = new List<List<int>>();
Edit
Report

1 Answer

2

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

answered 2011-06-04T17:51:02.750

Your Answer