Here I will show you the best way to use the enumeration:
public enum enumVIPBusinessPlanPaymentType { [Description("Monthly")] Monthly = 1, [Description("Paid In Full (PIF)")] PaidInFull = 2, [Description("Barter")] Barter = 3 }
and create the EnumHelper.cs class to read its value or description
public static Int32 GetIntValue(Enum en) { Type type = en.GetType(); return TemplateControlExtension.GetInt32(null, en); } public static string GetStringNameFromValue(Enum en) { Type type = en.GetType(); MemberInfo[] info = type.GetMember(en.ToString()); if (info != null && info.Length > 0) { object[] attrs = info[0].GetCustomAttributes(typeof(DescriptionAttribute), false); if (attrs != null && attrs.Length > 0) { return ((DescriptionAttribute)attrs[0]).Description; } } return TemplateControlExtension.GetString(null, en); }
I hope you will enjoy
source share