title: C# Generic List of Generic List of Multiple Types
body: <p>Here is an abstraction and simplification of my issue:</p>
  
  <p>I have a set of toys and a corresponding box for these toys. I want the user to be able to specify the largest type of toy that the box can hold:</p>
  
  <pre><code>public class Box&lt;T&gt; {}
  </code></pre>
  
  <p>then within the Box class I want to have a generic list of toys, but each toy contained within the box will have a generic type:</p>
  
  <pre><code>public class Box&lt;T&gt;
  {
      public List&lt;Toy&gt; = new List&lt;Toy&gt;();
      public bool Whatever;
  
      [member functions, constructors...]
      [The member functions will depend on T]
  }
  </code></pre>
  
  <p>The Toys class will look like this:</p>
  
  <pre><code>public class Toy&lt;T&gt; where T : struct //T is any type
  {
      public List&lt;T&gt; = new List&lt;T&gt;();
      public string Name;
      public string Color;
  
      [member functions, constructors...]
  }
  </code></pre>
  
  <p>I want to be able to create Toys with many different types and then insert them into a Box with another specified type. Then I'd like to be able to add boxes together returning a Box with the largest type.</p>
  
  <p>I really don't know how to begin. The list of a generic class with multiple types is really throwing me for a loop. I read various articles about using an abstract class or an interface, but haven't found an example or anything that accomplishes something similar to what I'm trying to do.</p>
  
  <p>Any assistance anybody could provide would be very appreciated.</p>
  
  <p>The solution can be in C# 4.0.</p>
  
  <p><strong>Possible Future Clarification:</strong></p>
  
  <p>I want Toy to be generic and accept a  argument at instantiation because Toy must also have a List as a member.</p>
  
  <p>The nested List within Toy is my main problem. I then want a list within Box that holds Toys, but each toy has as different  type constructor.</p>
  
  <h2>Update:</h2>
  
  <p>I fixed the Box to Box that was a typo.</p>
  
  <h2>Update 2:</h2>
  
  <pre><code>Toy&lt;plastic&gt; tyPlastic = new Toy&lt;plastic&gt;("Name1", Blue, new plastic[] {0xFFEE00, 0xF34684, 0xAA35B2});
  Toy&lt;wood&gt; tyWood = new Toy&lt;wood&gt;("Name2", Grain, new wood[] {a1, f4, h7});
  
  Box&lt;plastic&gt; bxBox = new Box&lt;plastic&gt;();//The Box has the ability to hold both plastic and wood toys.  Plastic &gt; Wood &gt; Paper
  </code></pre>
  
  <p>Final: I ended up removing the requirement for Box to be generic.  I then used reflection to create dynamically typed Toy.  Thanks everybody.</p>