<p>Does anyone know how to transform a enum value to a human readable value?</p>

<p>For example:</p>

<blockquote>
  <p>ThisIsValueA should be "This is Value A".</p>
</blockquote>

[{'answer_id': 13602, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 3, 'selected': False, 'text': '<p>Most examples of this that I\'ve seen involve marking your enum values up with [Description] attributes and using reflection to do the &quot;conversion&quot; between the value and the description. Here\'s an old blog post about it:</p>\n<p>&lt;<a href="https://web.archive.org/web/20201125032118/http://geekswithblogs.net/rakker/archive/2006/05/19/78952.aspx" rel="nofollow noreferrer">Link</a>&gt;</p>\n'}, {'answer_id': 13610, 'author': 'Scott Dorman', 'author_id': 1559, 'author_profile': 'https://Stackoverflow.com/users/1559', 'pm_score': 2, 'selected': False, 'text': '<p>You can also take a look at this article: <a href="http://www.codeproject.com/KB/cs/enumdatabinding.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/enumdatabinding.aspx</a></p>\n\n<p>It\'s specifically about data binding, but shows how to use an attribute to decorate the enum values and provides a "GetDescription" method to retrieve the text of the attribute. The problem with using the built-in description attribute is that there are other uses/users of that attribute so there is a possibility that the description appears where you don\'t want it to. The custom attribute solves that issue.</p>\n'}, {'answer_id': 13611, 'author': 'Adam Haile', 'author_id': 194, 'author_profile': 'https://Stackoverflow.com/users/194', 'pm_score': 2, 'selected': False, 'text': '<p>You can inherit from the "Attribute" class of System.Reflection to create your own "Description" class.  Like this (from <a href="http://blogs.msdn.com/abhinaba/archive/2005/10/20/483000.aspx" rel="nofollow noreferrer">here</a>):</p>\n\n<pre><code>using System;\nusing System.Reflection;\nnamespace FunWithEnum\n{\n    enum Coolness : byte\n    {\n        [Description("Not so cool")]\n        NotSoCool = 5,\n        Cool, // since description same as ToString no attr are used\n        [Description("Very cool")]\n        VeryCool = NotSoCool + 7,\n        [Description("Super cool")]\n        SuperCool\n    }\n    class Description : Attribute\n    {\n        public string Text;\n        public Description(string text)\n        {\n            Text = text;\n        }\n    }\n    class Program\n    {\n        static string GetDescription(Enum en)\n        {\n            Type type = en.GetType();\n            MemberInfo[] memInfo = type.GetMember(en.ToString());\n            if (memInfo != null &amp;&amp; memInfo.Length &gt; 0)\n            {\n                object[] attrs = memInfo[0].GetCustomAttributes(typeof(Description), false);\n                if (attrs != null &amp;&amp; attrs.Length &gt; 0)\n                    return ((Description)attrs[0]).Text;\n            }\n            return en.ToString();\n        }\n        static void Main(string[] args)\n        {\n            Coolness coolType1 = Coolness.Cool;\n            Coolness coolType2 = Coolness.NotSoCool;\n            Console.WriteLine(GetDescription(coolType1));\n            Console.WriteLine(GetDescription(coolType2));\n        }\n    }\n}\n</code></pre>\n'}, {'answer_id': 13613, 'author': 'Leon Bambrick', 'author_id': 49, 'author_profile': 'https://Stackoverflow.com/users/49', 'pm_score': 5, 'selected': True, 'text': '<p>Converting this from a vb code snippet that a certain Ian Horwill left at a <a href="http://secretgeek.net/progr_purga.asp" rel="noreferrer">blog post long ago</a>... i\'ve since used this in production successfully.</p>\n\n<pre><code>    /// &lt;summary&gt;\n    /// Add spaces to separate the capitalized words in the string, \n    /// i.e. insert a space before each uppercase letter that is \n    /// either preceded by a lowercase letter or followed by a \n    /// lowercase letter (but not for the first char in string). \n    /// This keeps groups of uppercase letters - e.g. acronyms - together.\n    /// &lt;/summary&gt;\n    /// &lt;param name="pascalCaseString"&gt;A string in PascalCase&lt;/param&gt;\n    /// &lt;returns&gt;&lt;/returns&gt;\n    public static string Wordify(string pascalCaseString)\n    {            \n        Regex r = new Regex("(?&lt;=[a-z])(?&lt;x&gt;[A-Z])|(?&lt;=.)(?&lt;x&gt;[A-Z])(?=[a-z])");\n        return r.Replace(pascalCaseString, " ${x}");\n    }\n</code></pre>\n\n<p>(requires, \'using System.Text.RegularExpressions;\')</p>\n\n<p>Thus:</p>\n\n<pre><code>Console.WriteLine(Wordify(ThisIsValueA.ToString()));\n</code></pre>\n\n<p>Would return, </p>\n\n<pre><code>"This Is Value A".\n</code></pre>\n\n<p>It\'s much simpler, and less redundant than providing Description attributes.</p>\n\n<p>Attributes are useful here only if you need to provide a layer of indirection (which the question didn\'t ask for).</p>\n'}, {'answer_id': 13641, 'author': 'John', 'author_id': 33, 'author_profile': 'https://Stackoverflow.com/users/33', 'pm_score': 0, 'selected': False, 'text': '<p>I found it best to define your enum values with an under score so ThisIsValueA would be This_Is_Value_A then you can just do a enumValue.toString().Replace("_"," ")  where enumValue is your varible.</p>\n'}, {'answer_id': 13697, 'author': 'Keith', 'author_id': 905, 'author_profile': 'https://Stackoverflow.com/users/905', 'pm_score': 4, 'selected': False, 'text': '<p>The .ToString on Enums is relatively slow in C#, comparable with GetType().Name (it might even use that under the covers).</p>\n\n<p>If your solution needs to be very quick or highly efficient you may be best of caching your conversions in a static dictionary, and looking them up from there.</p>\n\n<hr>\n\n<p>A small adaptation of @Leon\'s code to take advantage of C#3. This does make sense as an extension of enums - you could limit this to the specific type if you didn\'t want to clutter up all of them.</p>\n\n<pre><code>public static string Wordify(this Enum input)\n{            \n    Regex r = new Regex("(?&lt;=[a-z])(?&lt;x&gt;[A-Z])|(?&lt;=.)(?&lt;x&gt;[A-Z])(?=[a-z])");\n    return r.Replace( input.ToString() , " ${x}");\n}\n\n//then your calling syntax is down to:\nMyEnum.ThisIsA.Wordify();\n</code></pre>\n'}, {'answer_id': 52067663, 'author': 'Matt Williams', 'author_id': 3905343, 'author_profile': 'https://Stackoverflow.com/users/3905343', 'pm_score': 0, 'selected': False, 'text': '<p>An alternative to adding <code>Description</code> attributes to each enumeration is to create an extension method. To re-use Adam\'s "Coolness" enum:</p>\n\n<pre><code>public enum Coolness\n{\n    NotSoCool,\n    Cool,\n    VeryCool,\n    SuperCool\n}\n\npublic static class CoolnessExtensions\n{\n    public static string ToString(this Coolness coolness)\n    {\n        switch (coolness)\n        {\n            case Coolness.NotSoCool:\n                return "Not so cool";\n            case Coolness.Cool:\n                return "Cool";\n            case Coolness.VeryCool:\n                return "Very cool";\n            case Coolness.SuperCool:\n                return Properties.Settings.Default["SuperCoolDescription"].ToString();\n            default:\n                throw new ArgumentException("Unknown amount of coolness", nameof(coolness));\n        }\n    }\n}\n</code></pre>\n\n<p>Although this means that the descriptions are further away from the actual values, it allows you to use localisation to print different strings for each language, such as in my <code>VeryCool</code> example.</p>\n'}, {'answer_id': 68849180, 'author': 'osynavets', 'author_id': 9547346, 'author_profile': 'https://Stackoverflow.com/users/9547346', 'pm_score': 0, 'selected': False, 'text': '<pre><code>Enum.GetName(typeof(EnumFoo), EnumFoo.BarValue)\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/13599', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1154/']