Answers
Nov 24, 2006 - 12:17 AM
value is a string that contains the index
Array values = Enum.GetValues(typeof(MYENUM));
value = (string) values.GetValue(Convert.ToInt32(value));
Nov 26, 2006 - 12:24 PM
This works for me:
enum MyEnum {One = 1, Two = 2, Three = 3, Four = 4};
static void Main(string[] args) {
string strIndex = "2";
string value;
Array values = Enum.GetValues(typeof(MyEnum));
value = values.GetValue(Convert.ToInt32(strIndex)).ToString();
Console.WriteLine(value);
Console.Read();
}
Cheers
Peter
Dec 15, 2006 - 08:20 AM
I thought they automatically had an index from 0 and up...
Thanks for your help, Peter.
Dec 22, 2006 - 03:30 AM
Feb 19, 2012 - 10:04 AM
// Example -------------------------
enum MyEnum {One=1,Two=2}
private void echoEnumValue(MyEnum pParamEnum)
{
string msg = ((int)pParamEnum).ToString();
MessageBox.Show(msg);
}
Add New Comment