20 01 2009
Some time ago I wrote blog posting Extension method for enumerators where I showed how to use extension methods to make using of enumerators more convenient. Today I found very interesting posting from Grant Barrington blog where he describes the class called EnumHelper.
As enumerator values are often used on web forms as dropdown lists then we need a way to show nice options to users. Something like BrightPink or MyHomeAddress may confuse them. Grant offers us a nice solution – we can use description attributes to bind user readable values to enumerator members.
Take a look at the following code sample I took from Grant’s blog. It is the best illustration about his work.
public enum UserColours
BurntOrange = 1,
BrightPink = 2,
DarkGreen = 3,
SkyBlue = 4
It seems cool to me. Thanks Grant!