110,534
社区成员
发帖
与我相关
我的任务
分享
Type type = typeof(Button);
Object[] attrs = type.GetCustomAttributes(typeof(DescriptionAttribute), true);
if (attrs != null && attrs.Length > 0)
{
System.ComponentModel.DescriptionAttribute desAttr = attrs[0] as System.ComponentModel.DescriptionAttribute;
MessageBox.Show(desAttr.Description);
}
DescriptionAttribute[] das = typeof(_SourceType).GetField("Storage_Goods")
.GetCustomAttributes(typeof(DescriptionAttribute), false)
.OfType<DescriptionAttribute>().ToArray();
if (das.Length > 0)
Console.WriteLine(das[0].Description);
Console.WriteLine(typeof(_SourceType).GetField("Storage_Goods")
.GetCustomAttributesData()[0].ConstructorArguments[0].Value);