title: Is it possible to make "this type" for generics in C#?
body: <p><em>Kind of theoretical question. Quite long so feel free to skip if you are not in the mood for theory.</em></p>
  
  <p>Imagine that you have two classes, one inherited from another. The base class is generic and has a method that in the closed type must return some instance of this closed type. </p>
  
  <p>Like this (note <strong>???</strong> in text):</p>
  
  <pre><code>public class Adapter&lt;T&gt;
  {
   public virtual ??? DoSomething()
   {
    ...
   }
  }
  
  public class AdaptedString : Adapter&lt;String&gt;
  {
   public override AdaptedString DoSomething()
   {
    ...
   }
  }
  </code></pre>
  
  <p>I can't do it because there is no way to refer to a closed type that will be derived from a generic type. (Sorry for broken language, just don't know how to express it.) There is no keyword to set in place of <code>???</code> to specify that this method will return instance of type that would be derived from this generic type. </p>
  
  <p>Instead, I can use a workaround of explicitly passing the type name to the generic base. But it looks redundant.</p>
  
  <pre><code>public class Adapter&lt;TThis,T&gt;
  {
   public virtual TThis DoSomething()
   {
    ...
   }
  }
  
  public class AdaptedString : Adapter&lt;AdaptedString,String&gt;
  {
   public override AdaptedString DoSomething()
   {
    ...
   }
  }
  </code></pre>
  
  <p>And if in the base class I need to access members of <code>TThis</code> instance, I have to add a constraint. This time it looks ugly - note the constraint:</p>
  
  <pre><code>public class Adapter&lt;TThis,T&gt;
   where TThis : Adapter&lt;TThis, T&gt;
  {
   protected int _field; 
  
   ...
  
   public bool Compare( TThis obj )
   {
    return _field == obj._field;
   }
  }
  
  public class AdaptedString : Adapter&lt;AdaptedString,String&gt;
  {
   ...
  }
  </code></pre>
  
  <p>Yes, it is all working, but it would look better if I can simply use some keyword instead of <code>???</code> in first code fragment. Something like "<strong>thistype</strong>".</p>
  
  <p>How do you think will it work? Is it useful? Or maybe this is just plain stupid? </p>