TypeDescriptor.GetProperties() vs Type.GetProperties()

前端 未结 3 941
自闭症患者
自闭症患者 2020-12-05 22:39

Consider the following code.

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


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 23:35

    The TypeDescriptor class is used in designers, so that they can interact with the design-time environment. In particular, designers can override and extend various features of TypeDescriptor, but not Type.

    One good example is working with data-bound controls. The DataSource property is of type System.Object, yet at design-time, that property is replaced with a new property that has a richer design-time UI.

提交回复
热议问题