1 . EnumHelper - Getting a Friendly Description from an Enum
2. Enum: Binding to the Description Attribute
3)Enum Helper Get enum values to bind to a listcontrol
///
/// Get all the values of an enumeration of Type enumType and bind to a listcontrol
///
/// Enumeration type/// List control ///Array of objects
public static void BindEnumToListControl(Type enumType, ListControl lstControl)
{
Dictionaryenumslist = new Dictionary ();
foreach (int enumValue in Enum.GetValues(enumType))
{
enumslist.Add(enumValue,Enum.GetName(enumType, enumValue));
}
lstControl.DataTextField = "Value";
lstControl.DataValueField = "Key";
lstControl.DataSource = enumslist;
lstControl.DataBind();
}
4)To convert integer to enum
EnumType var = (EnumType)(Convert.ToInt16(Enum_value);
5)Get enum integer value -- check
int i = (byte)Enum.Parse(typeof(EnumTypestring), volume_value));
or
int i = (byte)EnumType.Item;
Feel free to leave your comments!!