title: Convert Enum Collection to Dictionary Given Type
body: <p>I'm looking to create a function that converts an Enum to a dictionary list. The Enum names will also be converted into a more human readable form. I'd like to just call the function,  provide the enum type, and get the dictionary back. I believe I'm almost there I just can't seem to figure out how to cast the enum to the correct type. (Getting an error on the 'returnList.Add' line). Right now I'm just using var for the type, however I do know the type, as it's passed in.</p>
  
  <pre><code>internal static Dictionary&lt;int,string&gt; GetEnumList(Type e)
  {
      List&lt;string&gt; exclusionList =
      new List&lt;string&gt; {"exclude"};
  
      Dictionary&lt;int,string&gt; returnList = new Dictionary&lt;int, string&gt;();
  
      foreach (var en in Enum.GetValues(e))
      {
          // split if necessary
          string[] textArray = en.ToString().Split('_');
  
          for (int i=0; i&lt; textArray.Length; i++)
          {
              // if not in the exclusion list
              if (!exclusionList
                  .Any(x =&gt; x.Equals(textArray[i],
                      StringComparison.OrdinalIgnoreCase)))
              {
                  textArray[i] = Thread.CurrentThread.CurrentCulture.TextInfo
                      .ToTitleCase(textArray[i].ToLower());
              }
          }
  
          returnList.Add((int)en, String.Join(" ", textArray));
      }
  
      return returnList;
  }
  </code></pre>