在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
}发布于 2010-07-21 21:50:04
使用typeof运算符:
if (c.DataType == typeof(string))
{
// ...
}发布于 2010-07-21 21:50:43
试试这个。
if (c.DataType == typeof(string)) {}发布于 2010-07-21 21:51:00
if (c.DataType == typeof(string))
{
// code
}https://stackoverflow.com/questions/3299917
复制相似问题