Alex Rivera | Logout

Get enum name when value is known

Asked 2010-07-25T03:29:48.287
40

I have an enum that has different colors in it. I would like to pass some function an int and have it return the color name that is in the enum in that position.

What's the way to do this?

Edit
Report

1 Answer

7

If your enum with colors is named MyColorEnumName, Try

Enum.GetName(typeof(MyColorEnumName),  enumColorValue)
answered 2010-07-25T03:36:33.923

Your Answer