Suppose I have several enums representing ... for example database vendors: Unknown
, Oracle
, Sybase
, SQL Server 2005
, SQL Server 2008
, etc. I want to let the user select between all of these but an Unknown
from a Combo Box. When the user selects an enum, they should see a human-readable description (which would hopefully come from an attribute). However, the actual object selected should be an enum of that specific type.
This can be hacked together manually with the help of extra dictionary, but I do not want to do that, and rather use an idiomatic and the cleanest way possible.
Would you kindly share a code sample, or at least a good link?
P.S. Is there an easy way to grab a collection of all enums of the type vendor, except for Unknown
(which will have a short/int value of 0
, as prescribed by Bill Wagner)?