
VB.NET,如何实现DataTable快速赋值给二维数组
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
展开全部
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();
}
}
追问
循环赋值,效率会低吗?
追答
应该会有影响,还要考虑你的数据量,不过现在计算机的处理速度应该都没有问题
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询