[英]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.