title: How to constraint a generic to be of type enum?
body: <p>Consider the following code:  </p>
  
  <pre><code>class Base&lt;T&gt;
  {
   //Base members
  }
  </code></pre>
  
  <p>I want the generic T to be an enum (using constraints if possible). How can I do this in C#?  </p>
  
  <p><strong>EDIT:</strong><br>
  Using code contracts -introduced by Akash Kava- also seems like a nice way. I managed to get it to produce a run time error which is useless.  <a href="http://codeviewer.org/view/code:2185" rel="nofollow">Here</a>'s the code I tried. It should be possible to generate a compile time warning but I can't get it to work.</p>