How to convert List> to an array of arrays

后端 未结 4 712
刺人心
刺人心 2020-12-08 19:40

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

List> lst = new List>();
         


        
4条回答
  •  自闭症患者
    2020-12-08 20:02

    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

提交回复
热议问题