要获取属性的描述/注释,需要使用System.ComponentModel命名空间中的DescriptionAttribute。可以通过反射获取属性上的DescriptionAttribute,并获取其Description属性值。
首先,需要引入System.ComponentModel命名空间:
using System.ComponentModel;
然后,代码如下:
// 获取Class的Type对象
Type type = orderDto.GetType();
// 获取Class的所有公共属性
PropertyInfo[] p