title: C#: Declaring and using a list of generic classes with different types, how?
body: <p>Having the following generic class that would contain either <strong><code>string, int, float, long</code></strong> as the type:</p>
  
  <pre><code>public class MyData&lt;T&gt;
  {
      private T _data;
  
      public MyData (T value)
      {
          _data = value;
      }
  
      public T Data { get { return _data; } }
  }
  </code></pre>
  
  <p>I am trying to get a list of <strong><code>MyData&lt;T&gt;</code></strong> where each item would be of different <strong><code>T</code></strong>.</p>
  
  <p>I want to be able to access an item from the list and get its value as in the following code:</p>
  
  <pre><code>MyData&lt;&gt; myData = _myList[0];    // Could be &lt;string&gt;, &lt;int&gt;, ...
  SomeMethod (myData.Data);
  </code></pre>
  
  <p>where <strong><code>SomeMethod()</code></strong> is declared as follows:</p>
  
  <pre><code>public void SomeMethod (string value);
  public void SomeMethod (int value);
  public void SomeMethod (float value);
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <p><strong><code>SomeMethod()</code></strong> is from another tier class I do not have control of and <strong><code>SomeMethod(object)</code></strong> does not exist.</p>
  
  <hr>
  
  <p>However, I can't seem to find a way to make the compiler happy.</p>
  
  <p>Any suggestions?</p>
  
  <p>Thank you.</p>