C# 特性Description的值的获取
作者:互联网
public class dataE{
/// <summary>
/// 企业名称
/// </summary>
/// <returns></returns>
[Description("企业名称")]
public string EnterpriseName { get; set; }
}
var data=new dataE();
AttributeCollection attributes =
TypeDescriptor.GetProperties(data)["EnterpriseName"].Attributes;
DescriptionAttribute myAttribute =
(DescriptionAttribute)attributes[typeof(DescriptionAttribute)];
Console.WriteLine(myAttribute.Description);
参考:
楚楚动人的明 发布了17 篇原创文章 · 获赞 0 · 访问量 235 私信 关注标签:Description,DescriptionAttribute,C#,获取,EnterpriseName,dataE,data,public 来源: https://blog.csdn.net/weixin_38110122/article/details/104050886