C# .net dotnet属性定义属性,以提供显示明称,默认值

//使用显示名称初始化 System.ComponentModel.DisplayNameAttribute 类的新实例。 displayName 显示名称
[DisplayName("weight")]
//初始化默认值 System.ComponentModel.DefaultValueAttribute 类的实例。支持所有类型,如字符串string,double,long,int,object,type,等等
[DefaultValue(100)]
public int Weight { get; set; }
原文地址:https://www.cnblogs.com/webenh/p/6138859.html