TypeDescriptor.GetProperties() vs Type.GetProperties()

Posted by Eric on Stack Overflow See other posts from Stack Overflow or by Eric
Published on 2009-09-09T21:36:56Z Indexed on 2010/03/13 20:15 UTC
Read the original article Hit count: 480

Filed under:
|
|
|

Consider the following code.

Object obj;
PropertyDescriptorCollection A = TypeDescriptor.GetProperties(obj);
PropertyInfo[] B = obj.GetType().GetProperties(); // EDIT*

I'm trying to understand the difference between A and B. From what I understand TypeDescriptor.GetProperties() will return custom TypeDescriptor properties, where as Type.GetProperties() will only return intrinsic "real" properties of the object. Is this right? If obj doesn't have any custom TypeDescriptor properties then it just defaults to also returning the literal intrinsic properties of the object.


* Original second line of code before EDIT (had wrong return value):

PropertyDescriptorCollection B = obj.GetType().GetProperties();

© Stack Overflow or respective owner

Related posts about type

Related posts about typedescriptor