title: C# Make a List to hold any derived children of a base class
body: <p>So I wish to setup an abstract base class to derive children classes from.  All the work will take place on the children, but I wanted the children to be able to reference each other.  </p>
  
  <p>Here is some pseudo-code:</p>
  
  <pre><code>public abstract class BaseClass&lt;T&gt; : SomeOtherClass {
  
      public List&lt;BaseClass&gt; listOfChildren;
  
      protected T thisChild;
  
      public void DoMoreStuff(){
          Debug.Log("Doing more stuff");
      }
  
      protected virtual void DoSomething(int i){
          listOfChildren[i].DoMoreStuff();
      }
  }
  
  public class FirstChildClass : BaseClass&lt;FirstChildClass&gt; {
  
      FirstChildClass&lt;T&gt;(){
          thisChild = this;
      }
  
      public void FirstClassStuff(){
          Debug.Log("first class stuff");
      }
  
  }
  public class SecondChildClass : BaseClass&lt;SecondChildClass&gt; {
  
      public void SecondClassStuff(){
          Debug.Log("second class stuff");
      }
  }
  </code></pre>
  
  <p>How would I make a generic List to accept any child class?</p>
  
  <p>Will I need to typecast listOfChildren with T to use DoMoreStuff()?</p>
  
  <p>On its own, is there anything else inherently wrong with this setup? </p>