记录
public class RemarkAttribute : Attribute { private string m_remark; public RemarkAttribute(string remark) { this.m_remark = remark; } public string Remark { get { return m_remark; } set { m_remark = value; } } public static string GetEnumRemark(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); string name = string.Empty; foreach (RemarkAttribute attr in attrs) { name = attr.Remark; } return name; } } /// <summary> /// 用户类型 /// </summary> public enum userType { /// <summary> /// 会员 /// </summary> [Remark("user")] user = 1, /// <summary> /// 商家 /// </summary> [Remark("merchant")] merchant = 2, /// <summary> /// 月嫂 /// </summary> [Remark("issuser")] issuser = 4 }