title: Generic contraints on derived classes
body: <p><strong>I have class A:</strong></p>
  
  <pre><code>public class ClassA&lt;T&gt;
  </code></pre>
  
  <p><strong>Class B derives from A:</strong></p>
  
  <pre><code>public class ClassB : ClassA&lt;ClassB&gt;
  </code></pre>
  
  <p><strong>Class C derives from class B:</strong></p>
  
  <pre><code>public class ClassC : ClassB
  </code></pre>
  
  <p><strong>Now I have a generic method with constraints</strong></p>
  
  <pre><code>public static T Method&lt;T&gt;() where T : ClassA&lt;T&gt;
  </code></pre>
  
  <p>OK, now I want to call:</p>
  
  <pre><code>ClassC c = Method&lt;ClassC&gt;();
  </code></pre>
  
  <p>but I get the compile error saying:
  <code>Type argument 'ClassC' does not inherit from or implement the constraint type 'ClassA&lt;ClassC&gt;.</code></p>
  
  <p>Yet, the compiler will allow:</p>
  
  <pre><code>ClassB b = Method&lt;ClassB&gt;();
  </code></pre>
  
  <p>My understanding is that this fails because <code>ClassC</code> inherits <code>ClassA&lt;ClassB&gt;</code> instead of <code>ClassA&lt;ClassC&gt;</code></p>
  
  <p><strong>My real question is, is it possible to create a class deriving from <code>ClassB</code> that can be used in some way with the generic method?</strong></p>
  
  <p>This may seem like generics are overused and I would agree.  I am trying to create business layer objects deriving from the subsonic data objects in a separate project.</p>
  
  <p>Note: I have put the &lt; T > with extra spaces otherwise they get stripped from the question.</p>