title: How to convert from System.Enum to base integer?
body: <p>I'd like to create a generic method for converting any System.Enum derived type to its corresponding integer value, without casting and preferably without parsing a string.</p>
  
  <p>Eg, what I want is something like this:</p>
  
  <pre><code>// Trivial example, not actually what I'm doing.
  class Converter
  {
      int ToInteger(System.Enum anEnum)
      {
          (int)anEnum;
      }
  }
  </code></pre>
  
  <p>But this doesn't appear to work. Resharper reports that you can not cast expression of type 'System.Enum' to type 'int'.</p>
  
  <p>Now I've come up with this solution but I'd rather have something more efficient.</p>
  
  <pre><code>class Converter
  {
      int ToInteger(System.Enum anEnum)
      {
          return int.Parse(anEnum.ToString("d"));
      }
  }
  </code></pre>
  
  <p>Any suggestions?</p>