Convert Enum to String
- by Eric Weilnau
Which is the preferred way to convert an Enum to a String in .NET 3.5?
Enum.GetName
Enum.Format
toString
Why should I prefer one of these over the others? Does one perform better?
Justification for Accepted Answer
Based on the forum post in panesofglass answer, it appears that Microsoft indirectly endorses the following method of converting an enum value to a string.
Do not convert an enum value to a string using built-in enum methods.
...
This will cause problems when Dotfuscating. You should not use enum.ToString(), enum.GetNames(), enum.GetName(), enum.Format() or enum.Parse() to convert an enum to a string. Instead, use a switch statement, and also internationalize the names if necessary.