title: Instantiating a type-constrained generic class without subclassing it
body: <p><strong>Background</strong></p>
  
  <p>[Skip to <strong>Question</strong> if you're not interested in the background]</p>
  
  <p>I stumbled across this generic class definition when reading the other day, and it stumped me for some time:</p>
  
  <pre><code>public abstract class Entity&lt;T&gt; where T : Entity&lt;T&gt;
  </code></pre>
  
  <p>I was puzzled as to how <code>T</code> on <code>Entity&lt;T&gt;</code> could be of Type <code>Entity&lt;T&gt;</code> itself. It seemed some sort of bizarre recursive constraint.</p>
  
  <p>I then realised that this constraint could be satisfied by subclassing (which is, of course, what <code>abstract</code> is demanding of the class):</p>
  
  <pre><code>public class Deriver : Entity&lt;Deriver&gt;
  </code></pre>
  
  <p>Here, type <code>T</code> is garanteed to be of type <code>Entity&lt;T&gt;</code> because <code>Deriver</code> derives from <code>Entity&lt;Deriver&gt;</code>.</p>
  
  <p><strong>Question</strong></p>
  
  <p>Anyhow, it led me to wonder, if the class was not abstract, could we instantitate it directly?</p>
  
  <p>So given</p>
  
  <pre><code>class Entity&lt;T&gt; where T : Entity&lt;T&gt;
  </code></pre>
  
  <p>Can we instantitate <code>Entity&lt;T&gt;</code> directly?</p>
  
  <p>Obviously we can't say:</p>
  
  <pre><code>Entity&lt;SomeClass&gt; e = new Entity&lt;SomeClass&gt;();
  </code></pre>
  
  <p>Because <code>SomeClass</code> doesn't satisfy the constraint <code>where T : Entity&lt;T&gt;</code>.</p>
  
  <p>Ignoring the obvious "Why would you want to do that?" is this essentially is a way of ensuring a class is dervied before you can use it without using the <code>abstract</code> keyword? </p>