Datatable to Multidimensional Array

前端 未结 3 1999
野性不改
野性不改 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 02:39

    yourTable.AsEnumerable().Select(row => row.ItemArray).ToArray()

    0 讨论(0)
  • 2020-12-07 02:40

    try dt.Rows.Cast().Select(//datarow to strings)

    0 讨论(0)
  • 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();
    
    0 讨论(0)
提交回复
热议问题