MyEnum.test1.ToString( );
or
Enum.GetName ( typeof ( MyEnum ) , MyEnum.test1 )
or
Enum.GetNames ( typeof ( MyEnum ) ) [ 0 ]
> hey all,
> is there anyway to ask the Enum what the string value is with a given
[quoted text clipped - 12 lines]
> thanks,
> rodchar
Jeroen - 30 Jan 2008 15:13 GMT
What is "none of the above", Alex?
All options will cause you problems if you obfuscate your code, found
that one out the hard way ;-).
Regards,
Jeroen
PS. If this thread was meant as a particular question, then I missed
it...
Ignacio Machin ( .NET/ C# MVP ) - 30 Jan 2008 21:11 GMT
Hi,
Could you elaborate in what happened to you?
thanks,

Signature
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
> What is "none of the above", Alex?
>
[quoted text clipped - 6 lines]
> PS. If this thread was meant as a particular question, then I missed
> it...
Alun Harford - 30 Jan 2008 21:21 GMT
> What is "none of the above", Alex?
>
> All options will cause you problems if you obfuscate your code, found
> that one out the hard way ;-).
Hmm... then somewhere you needed to map those enums to strings, which
suggests the obfuscation was totally pointless anyway. As per usual.
Alun Harford
rodchar - 30 Jan 2008 15:15 GMT
Thanks Gerry, i appreciate it.
rod.
> MyEnum.test1.ToString( );
>
[quoted text clipped - 22 lines]
> > thanks,
> > rodchar
Ben Voigt [C++ MVP] - 30 Jan 2008 21:33 GMT
> MyEnum.test1.ToString( );
ok, but you specified the enum element by name already
> or
>
> Enum.GetName ( typeof ( MyEnum ) , MyEnum.test1 )
ok, but you specified the enum element by name again
> or
>
> Enum.GetNames ( typeof ( MyEnum ) ) [ 0 ]
This returns the first name, not the name corresponding to the value (0).
>> hey all,
>> is there anyway to ask the Enum what the string value is with a given
[quoted text clipped - 12 lines]
>> thanks,
>> rodchar
> hey all,
> is there anyway to ask the Enum what the string value is with a given
[quoted text clipped - 9 lines]
> This won't work but may better explain:
> String a = MyEnum[1];
int i = 1;
((Myenum)i).ToString();
> thanks,
> rodchar