Recording
Public classRemarkattribute:attribute {Private stringM_remark; PublicRemarkattribute (stringremark) { This. M_remark =remark; } Public stringRemark {Get{returnM_remark;} Set{M_remark =value;} } Public Static stringGetenumremark (Enum val) {Type type=val. GetType (); FieldInfo FD=type. GetField (Val. ToString ()); if(FD = =NULL) return string. Empty; Object[] Attrs = FD. GetCustomAttributes (typeof(Remarkattribute),false); stringName =string. Empty; foreach(Remarkattribute attrinchattrs) {Name=attr. Remark; } returnname; } } /// <summary> ///User Type/// </summary> Public enumusertype {/// <summary> ///member/// </summary>[Remark ("User")] User=1, /// <summary> ///Merchant/// </summary>[Remark ("Merchant")] Merchant=2, /// <summary> ///Sister Yue/// </summary>[Remark ("Issuser")] Issuser=4 }
Attribute Adding a comment to an enumeration