![](/img/trans.png)
[英]How to compare a Microsoft.CodeAnalysis.ITypeSymbol to a System.Type
[英]How to compare to System.Type?
在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
}
使用typeof
运算符:
if (c.DataType == typeof(string))
{
// ...
}
尝试这个...
if (c.DataType == typeof(string)) {}
if (c.DataType == typeof(string))
{
// code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.