在DataSet.Tables[0].Columns[0]
我们有一个DataType
属性。现在,我想遍历Columns
并根据DataType
中的Type
执行一些操作。这个怎么做?如何比较System.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是字符串)'。 – Marc 2010-07-21 13:56:02
@马克:这不是一回事。 'c.DataType'是'Type',而不是'string'。您的代码将始终评估为false。 – LukeH 2010-07-21 14:00:33
我想知道我错过了什么,谢谢!我发表了这个评论,希望它会受到指责或证实。 – Marc 2010-07-21 14:02:17