【问题标题】:Reflection Type vs TypeDescriptor反射类型与类型描述符
【发布时间】:2014-04-13 04:53:52
【问题描述】:

最近我一直在使用反射来处理我的项目,我有一个当前的问题。

Type.GetProperties(Flags) 中,我们可以使用“标志”过滤我们获得的属性;在TypeDescriptor.GetProperties(),我们没有。

type.GetProperties 中,我可以过滤以仅获取未继承的属性。 是否可以对TypeDescriptor.GetProperties() 做同样的事情(只有未继承的属性)?

谢谢

【问题讨论】:

标签: c# reflection typedescriptor


【解决方案1】:

不,你不能。

TypeDescriptor.GetProperties() 用于获取PropertyDescriptor 实例,并可以使用特定的Attributes 进行过滤。

Type.GetProperties() 用于获取PropertyInfo 实例,并可以使用特定的BindingFlags 进行过滤。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-24
    • 2015-01-22
    • 2019-06-22
    • 2017-12-15
    • 1970-01-01
    • 2021-06-26
    • 2021-10-11
    相关资源
    最近更新 更多