DataTable dt = new DataTable();
int col = dt.Columns.Count;
string[,] array = new string[dt.Rows.Count,col];
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
array[i, j] = dt.Rows[i][j].ToString().ToUpper().Trim();
}
}
int col = dt.Columns.Count;
string[,] array = new string[dt.Rows.Count,col];
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
array[i, j] = dt.Rows[i][j].ToString().ToUpper().Trim();
}
}

本文介绍了一种将DataTable转换为二维字符串数组的方法,并演示了如何通过遍历DataTable的每一行每一列来实现数据转换。该过程包括初始化DataTable、获取列数、创建数组以及使用嵌套循环填充数组中的每个元素。
1068

被折叠的 条评论
为什么被折叠?



