110,535
社区成员
发帖
与我相关
我的任务
分享
PropertyInfo pi = typeof(Desc).GetProperty("des");
foreach (object obj in pi.GetCustomAttributes(false))
{
if (obj is DescriptionAttribute)
{
MessageBox.Show((obj as DescriptionAttribute).Description);
break;
}
}
PropertyDescriptor pd = TypeDescriptor.GetProperties(typeof(Desc))["des"];
DescriptionAttribute description = pd == null ? null : pd.Attributes[ typeof(DescriptionAttribute) ] as DescriptionAttribute;
if (description != null)
{
MessageBox.Show(description.Description);
}