在
DataSet.Tables[0].Columns[0]
中,我们有一个 DataType
属性。现在,我想遍历 Columns
并根据 DataType
中的 Type
执行一些操作。如何做到这一点?foreach(var c in DataSet.Tables[0].Columns)
{
if (c.DataType == System.String) {} //error 'string' is a 'type', which is not valid in the given context
}
c.DataType
是一个Type
,而不是一个字符串。你的代码将始终为假。 - LukeH