title: C# Generics and polymorphism: an oxymoron?
body: <p>I just want to confirm what I've understood about Generics in C#.  This has come up in a couple code bases I've worked in where a generic base class is used to create type-safe derived instances.  A very simple example of what I'm talking about,</p>
  
  <pre><code>public class SomeClass&lt;T&gt;
  {
      public virtual void SomeMethod(){ }
  }
  
  public class DeriveFrom :SomeClass&lt;string&gt;
  {
      public override void SomeMethod()
      {
          base.SomeMethod();
      }
  }
  </code></pre>
  
  <p>The problem comes up when I then want to use derived instances in a polymorphic way.</p>
  
  <pre><code>public class ClientCode
  {
      public void DoSomethingClienty()
      {
          Factory factory = new Factory();
          //Doesn't compile because SomeClass needs a type parameter!
          SomeClass someInstance = factory.Create();
  
          someInstance.SomeMethod();
      }
  }
  </code></pre>
  
  <p>It seems that once you introduce a Generic into an inheritance hierarchy or interface, you can no longer use that family of classes in a polymorphic way except perhaps internal to itself.  Is that true?</p>