title: Specifying the return type of an abstract method from a Base Class according to a Sub Class
body: <p>I have the following structure:    </p>
  
  <pre><code>abstract class Base {
          public abstract List&lt;...&gt; Get(); //What should be the generic type?
  }
  
  class SubOne : Base {
      public override List&lt;SubOne&gt; Get() {
  
      }
  }
  
  class SubTwo : Base {
      public override List&lt;SubTwo&gt; Get() {
  
      }
  }
  </code></pre>
  
  <p>I want to create an abstract method that returns whatever class the concrete sub class is.  So, as you can see from the example, the method in <code>SubOne</code> should return <code>List&lt;SubOne&gt;</code> whereas the method in <code>SubTwo</code> should return <code>List&lt;SubTwo&gt;</code>.</p>
  
  <p>What type do I specify in the signature declared in the Base class ?</p>
  
  <hr>
  
  <p><strong>[UPDATE]</strong></p>
  
  <p>Thank you for the posted answers.</p>
  
  <p>The solution is to make the abstract class generic, like such:</p>
  
  <pre><code>abstract class Base&lt;T&gt; {
          public abstract List&lt;T&gt; Get();
  }
  
  class SubOne : Base&lt;SubOne&gt; {
      public override List&lt;SubOne&gt; Get() {
  
      }
  }
  
  class SubTwo : Base&lt;SubTwo&gt; {
      public override List&lt;SubTwo&gt; Get() {
  
      }
  } 
  </code></pre>