如何使用C中的数据表填充string[]类型的数组#

如何使用C中的数据表填充string[]类型的数组#,string,String,我在填充方面遇到了一个问题 使用数据表的字符串双数组。 请帮忙 字符串[][]导出=函数() 您可能想做这样的事情: (dt是您的数据表) string[]myArray=新字符串[dt.Rows.Count][dt.Columns.Count]();//声明新的二维数组 for(i=0;i

我在填充方面遇到了一个问题 使用数据表的字符串双数组。 请帮忙


字符串[][]导出=函数()

您可能想做这样的事情:
(dt是您的数据表)


string[]myArray=新字符串[dt.Rows.Count][dt.Columns.Count]();//声明新的二维数组
for(i=0;i
您试过什么吗?数据表中有哪些数据?您希望将哪些数据放入数组?实现
函数
将是一个很好的第一步。尽管将其称为“函数”可能是个坏主意。下面是完整的代码:string[][]myArray=newstring[dt.Rows.Count][dt.Columns.Count]();//为(i=0;istring[][] myArray = new string[dt.Rows.Count][dt.Columns.Count](); // Declare the new 2d array for(i=0; i < dt.Rows.Count-1; i++) // Iterate through the rows { for(j=0; j < dt.Columns.Count-1; j++) // Iterate through the columns { myArray[i][j] = dt.Rows[i][j]; // Populate the array with the cell data. } } return myArray