title: How do I create a custom Object type class in C#?
body: <p>I've got a situation where I have several classes that have somethings in common and somethings unique.  I'd like to create a class that is more strongly typed than object[] but could hold any of these other classes.</p>
  
  <p>If I have for example:</p>
  
  <pre><code>class MyType1
  {
     string common1;
     string common2;
     string type1unique1;
     string type1unique2;
  
     //Constructors Here 
  }
  
  class MyType2
  {
     string common1;
     string common2;
     string type2unique1;
     string type2unique2;
  
     //Constructors Here 
  }
  </code></pre>
  
  <p>I'd like to create a class something like:</p>
  
  <pre><code>class MyObject
  {
     string common1;
     string common2;
  
     //Code Here 
  }
  </code></pre>
  
  <p>So that I create something like:</p>
  
  <pre><code>Dictionary&lt;int, MyObject&gt;
  </code></pre>
  
  <p>That would hold either MyType1 or MyType2 but not string or int or anything else a dictionary would hold.  The MyObjects that are stored there would need to be able to be recast to MyType1 or MyType2 later to access the unique attributes underneath.</p>
  
  <p>Also it would be really great if I could access MyObject.common1 or MyObject.common2 without recasting it.</p>