Datatable to Multidimensional Array

前端 未结 3 2001
野性不改
野性不改 2020-12-07 01:59

Is there an easy way to convert a Datatable to a multidimensional string array?

Maybe using LINQ?

There\'s gotta be a better way than manually l

3条回答
  •  北海茫月
    2020-12-07 03:01

    Linq is the answer. You can convert a DataTable to IEnumerable using the AsEnumerable method. Then, the ToArray() converts it to an array.

    var tableEnumerable = DataTableName.AsEnumerable();
    tableArray = tableEnumerable.ToArray();
    

提交回复
热议问题