gpt4 book ai didi

c# - 如何使用 C# 'foreach' DataTable 中的列?

转载 作者:IT王子 更新时间:2023-10-29 03:49:47 26 4
gpt4 key购买 nike

如何使用 foreach 遍历数据行中的每一列?

DataTable dtTable = new DataTable();
MySQLProcessor.DTTable(mysqlCommand, out dtTable);

foreach (DataRow dtRow in dtTable.Rows)
{
//foreach(DataColumn dc in dtRow)
}

最佳答案

这应该有效:

DataTable dtTable;

MySQLProcessor.DTTable(mysqlCommand, out dtTable);

// On all tables' rows
foreach (DataRow dtRow in dtTable.Rows)
{
// On all tables' columns
foreach(DataColumn dc in dtTable.Columns)
{
var field1 = dtRow[dc].ToString();
}
}

关于c# - 如何使用 C# 'foreach' DataTable 中的列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7939146/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com