【发布时间】:2010-11-08 11:17:24
【问题描述】:
我正在编写一个使用反射来列出类的静态属性的方法,但我只对特定类型的属性感兴趣(在我的情况下,属性必须是从 DataTable 派生的类型)。我想要的是类似于下面的 if() 语句(目前总是返回 true):
PropertyInfo[] properties = ( typeof(MyType) ).GetProperties( BindingFlags.Public
| BindingFlags.Static );
foreach( PropertyInfo propertyInfo in properties ) {
if( !( propertyInfo.PropertyType is DataTable ) )
continue;
//business code here
}
谢谢,我被难住了。
【问题讨论】:
标签: c# reflection static properties types