在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