Frequently, you will have a situation where you store the string representation of an enumerated value in a file or database, and when it is retrieved you have to re-assign it to a variable that is of the enumerated type. You can do this as follows:
MyEnumeratedType enumVariable = (MyEnumeratedType) Enum.Parse(typeof(MyEnumeratedType), “Bar”, true);
With all due respect to Anders, this is NUTS!!! I wish there was a simpler way…
Remember Me
a@href@title, b, i, u
Contact me: nik*kalyani.com (replace "*")
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.