Search code examples
c#reflectiontypedescriptor

Reflection Type vs TypeDescriptor


Lately I have been using reflection to work in my project, and I have the current question.

While in Type.GetProperties(Flags), we can filter the properties we get using 'Flags'; in TypeDescriptor.GetProperties(), we don't.

In type.GetProperties I can filter to get only properties not inherited. Is it possible to do the same with TypeDescriptor.GetProperties() (only properties not inherited)?

Thank you


Solution

  • No, you can't.

    The TypeDescriptor.GetProperties() is used to get PropertyDescriptor instances with possibility to filter using specific Attributes.

    The Type.GetProperties() is used to get PropertyInfo instances with possibility to filter using specific BindingFlags.