title: Using enum as generic type parameter in C#
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1331739/enum-type-constraints-in-c">Enum type constraints in C#</a>  </p>
  </blockquote>
  
  
  
  <p>Is it possible to use <code>enum</code> types as a generic paramter by using its wrapper class <code>Enum</code>?</p>
  
  <p>I have different enums:</p>
  
  <pre><code>enum errors1 { E1, E3, E8 };
  enum errors2 { E0, E2, E9 };
  enum errors3 { E7, E4, E5 };
  </code></pre>
  
  <p>With the following class declaration I thought I could achieve it:</p>
  
  <pre><code>public class MyErrors&lt;T&gt; where T : Enum
  {
     T enumeration;
  
     public T getEnumeration()
     {
         return enumeration;
     }
  
     static void Main(string[] args)
     {
  
         Program&lt;error1&gt; p = new Program&lt;error1&gt;();
         p.getEnumeration().E1  // this call does NOT work
     }
  </code></pre>
  
  <p>However, since the general type is <code>Enum</code> I can only access the member and methods of the <code>Enum</code> class. So is it possible to implement it the way I meant to or what other approach should I use?</p>