请考虑以下代码.
Object obj;
PropertyDescriptorCollection A = TypeDescriptor.GetProperties(obj);
PropertyInfo[] B = obj.GetType().GetProperties(); // EDIT*
Run Code Online (Sandbox Code Playgroud)
我试图理解A和B之间的区别.根据我的理解,TypeDescriptor.GetProperties()将返回自定义TypeDescriptor属性,其中Type.GetProperties()将仅返回对象的内在"真实"属性.这是正确的吗?如果obj没有任何自定义TypeDescriptor属性,那么它只是默认返回对象的文字内在属性.
* EDIT之前的原始第二行代码(返回值错误):
PropertyDescriptorCollection B = obj.GetType().GetProperties();