我在第二个foreach循环中遇到此错误,对我来说逻辑似乎很好..:
(foreach语句无法对'datatable'类型的变量进行操作,因为'datatable'不包含'GetEnumerator'的公共实例定义)
foreach (DataTable testdatatable in test)
{
foreach (DataRow datarow in testdatatable)
{
string value = datarow.Field<string>("Slave_IO_Running"); //Looks for "Slave_IO_Running" status.
if (value == "Yes")
{
results.Add(siteName + ": WORKING"); //adds working to the visual table
}
else
{
results.Add(siteName + ": REPLICATION ERROR"); //adds not working to the result list
}
break;
}
}
答案 0 :(得分:2)
迭代DataTable.Rows属性:
foreach (DataRow datarow in testdatatable.Rows)