title: C# Create Instance of Generic class which inheritance from base
body: <p>I'm trying to create instance of class Bar but I'm receiving an error: </p>
  
  <blockquote>
    <p>"Cannot implicitly convert type <code>ConsoleApplication1.Bar</code> to
    <code>ConsoleApplication1.BaseFoo&lt;ConsoleApplication1.baseOutput,
    ConsoleApplication1.baseInput&gt;</code>"</p>
  </blockquote>
  
  <p>Any idea what I'm missing or what I'm doing wrong? Any advice will be nice.</p>
  
  <pre><code>public class baseOutput
  {
      public string output;
  }
  
  public class baseInput
  {
      public string input;
  }
  
  public class ExtendOutput : baseOutput
  {
      public long id;
  }
  
  public class ExtendInput : baseInput
  {
      public long id;
  }
  
  public class BaseFoo&lt;baseOutput, baseInput&gt;
  {
      protected virtual void DoSmth()
      {
  
      }
  }
  
  public class Bar : BaseFoo&lt;ExtendOutput, ExtendInput&gt;
  {
      protected override void DoSmth()
      {
          base.DoSmth();
      }
  }
  
  public class Test
  {
      public void Show()
      {
  
      }
  
      private BaseFoo&lt;baseOutput, baseInput&gt; CreateInstance()
      {
          return new Bar(); // Error right here
      }
  }
  </code></pre>