Posts

Showing posts from November 10, 2013

.NET Enums

Image
I like Enum . I love how you can define an Enum like this: Enum ColorType Red Green Blue End Enum Then use it as a parameter type like this: Public Sub ProcessColor(color As ColorType ) End Sub And when you go to use it in a method you get intellisense like this: Every so often I come across a data model that uses strings to signify types. Like an 'R' for Red and 'G' for Green and a 'B' for Blue. I would love to use my good friend Enum  and go: Enum ColorType Red = "R" Green = "G" Blue = "B" End Enum But unfortunately this is not possible.  If you are like me and wish you could do this please go here:  http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2161129-string-enum-for-both-c-and-vb  and Vote now. Until we get enough votes to get this implemented my current favorite alternativ