//This example will parse a string to a Keys value
Keys key = (Keys)Enum.Parse(typeof(Keys), "Space");
//The key value will now be Keys.Space
int something = (int) Question.Role;
System.Type enumType = typeof(TestEnum);
System.Type enumUnderlyingType = System.Enum.GetUnderlyingType(enumType);
System.Array enumValues = System.Enum.GetValues(enumType);
for (int i=0; i < enumValues.Length; i++)
{
// Retrieve the value of the ith enum item.
object value = enumValues.GetValue(i);
// Convert the value to its underlying type (int, byte, long, ...)
object underlyingValue = System.Convert.ChangeType(value, enumUnderlyingType);
System.Console.WriteLine(underlyingValue);
}
nameof(Weekdays.Monday) // Returns "Monday"
object underlyingValue = Convert.ChangeType(value, Enum.GetUnderlyingType(value.GetType()));
string name=(weekdays)2;//returns weekdays which has value 2.Here weekdays is enum name
arrayName variable = (arrayName) index
//for example
Days day = (Days)3;