TypeDescriptor.GetProperties() vs Type.GetProperties()
- by Eric
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();