title: How to pass a value to a C# generic?
body: <p>In C++ templates have the feature that you can pass a value as the argument to the <a href="http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlcpp8l.doc/language/ref/template_non-type_arguments.htm" rel="noreferrer">template of a function</a>. How can I do the same in C#?</p>
  
  <p>For instance, I want to do something similar to the following: </p>
  
  <pre><code>template &lt;unsigned n&gt; struct Factorial {
       enum { 
          result = n * Factorial&lt;n - 1&gt;::result;
       };
  };
  template &lt;&gt; struct Factorial&lt;0&gt; {
        enum {
          result = 1;
        };
  };
  </code></pre>
  
  <p>but in C#. How can I do this?</p>
  
  <p>By the way, my actual need for them involves generating classes on demand (with a few static values changed), so the presented code is just an example.</p>