Umbrella eases the use of the Enum.Parse method, as well as the ability to change the literal representation of an enumerated value.

For instance, with the following enumeration :

   enum Color
   {
      [Description("R")]
      Red,

      Green,

      [Description("B")]
      Blue
   }
Note that the Description attribute is not mandatory and is used only if present. If not, the literal representation of the enumerable value is used.

The enumeration values can be converted like this :

   Color red = "R".Conversion().To<Color>();
   Color green = "Green".Conversion().To<Color>();
   var isTrue = Color.Blue.Conversion().To<string>() == "B";

Last edited Feb 24, 2009 at 2:52 AM by jlaban, version 4

Comments

Qwertie Apr 26, 2011 at 1:24 AM 
Re: the title "Convert a string to an enumerable" - an enumeration is not the same thing as an enumerable (IEnumerable).