title: How can I use interface as a C# generic type constraint?
body: <p>Is there a way to get the following function declaration?</p>
  
  <pre><code>public bool Foo&lt;T&gt;() where T : interface;
  </code></pre>
  
  <p>ie. where T is an interface type (similar to <code>where T : class</code>, and <code>struct</code>).</p>
  
  <p>Currently I've settled for:</p>
  
  <pre><code>public bool Foo&lt;T&gt;() where T : IBase;
  </code></pre>
  
  <p>Where IBase is defined as an empty interface that is inherited by all my custom interfaces... Not ideal, but it should work... Why can't you define that a generic type must be an interface?</p>
  
  <p>For what it's worth, I want this because <code>Foo</code> is doing reflection where it needs an interface type... I could pass it in as a normal parameter and do the necessary checking in the function itself, but this seemed a lot more typesafe (and I suppose a little more performant, since all the checks are done at compiletime).</p>