你需要循环loadDT.Columns
,像这样:
foreach (DataColumn column in loadDT.Columns) { Console.Write("Item: "); Console.Write(column.ColumnName); Console.Write(" "); Console.WriteLine(row[column]); }
foreach (DataRow row in dt.Rows) { foreach (DataColumn column in dt.Columns) { ColumnName = column.ColumnName; ColumnData = row[column].ToString(); } }