title: Interface for method that returns its own type
body: <p>I have a situation where i have a class</p>
  
  <pre><code>class Foo
  {
      Foo Bar()
      {
          return new Foo();
      }
  }
  </code></pre>
  
  <p>Now i wan tot create an interface for it</p>
  
  <pre><code>class IFoo
  {
      ??? Bar();
  }
  </code></pre>
  
  <p>What should be in place of the question marks?  Each class should return it's own type, not Foo.</p>
  
  <p>The solutions below work but do not looks clean.  I don't understand why i have to specify the same class twice, and there is nothing like "this" for the current type</p>
  
  <p>This is how i am using it later</p>
  
  <pre><code>class GenericClass&lt;T&gt; where T : IFoo
  { 
      T foo = new T();
      T item = foo.Bar();
  }
  </code></pre>