title: reference the "self" type in a static method - C#
body: <p>I am trying to create a static method that would return an instance of the class, something like:</p>
  
  <pre><code>class A {
     public static A getInstance() {
        return new A();
     }
  }
  </code></pre>
  
  <p>The problem I am having is that if I have a subclass B derived from A, I would like B.getInstance() to return an instance of B, and not A. In PHP world, you could use a keyword "self" to reference to your own type, so your getInstance() would look like:</p>
  
  <pre><code>public static function getInstance() {
     return new self();
  }
  </code></pre>
  
  <p>What's the best way to go about this?</p>