检查属性是否为布尔类型

3

我正在使用反射(Reflection)循环遍历当前实例的属性,并尝试确定一个属性是否为 Boolean 类型。我尝试了许多方法(例如 typeof、GetType 等),但都无法运行。以下是我的代码:

For Each prop As System.Reflection.PropertyInfo In Me.GetType.GetProperties()
     If prop.PropertyType Is Boolean Then 'Not Compiling
         ' Do Something if boolean
     End If
Next

2
尝试 If prop.PropertyType Is GetType(Boolean) Then - Ňɏssa Pøngjǣrdenlarp
1个回答

9

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接