I am searching a solution to get the complete String of an enum.
Example:
Public Enum Color
{
Red = 1,
Blue = 2
}
Color color = Color.Red;
/
Fast variant that works for every enum
public static class EnumUtil where TEnum : struct
{
public static readonly Dictionary _cache;
static EnumUtil()
{
_cache = Enum
.GetValues(typeof(TEnum))
.Cast()
.ToDictionary(x => x, x => string.Format("{0}.{1}", typeof(TEnum).Name, x));
}
public static string AsString(TEnum value)
{
return _cache[value];
}
}