title: C# Data structure that accepts different data types and maintains insertion order
body: <p>In C#, I can have a Hashtable that accepts different data types for the values. But I want a datastructure that can maintain the insertion order.</p>
  <p>I am coming to C# from Java background and I would like to know a clean way of solving it. I don't want the O(1) lookup complexity of an Hashtable.</p>
  <p>Here is how my Hashtable would be.</p>
  <pre><code>public void foo() {
      List&lt;string&gt; mylist1 = new List&lt;string&gt;(new string[] { &quot;1&quot;, &quot;2&quot;, &quot;3&quot; });
      List&lt;int&gt; mylist2 = new List&lt;int&gt;(new int[] { 1, 2, 3 });
      Hashtable hashTable = new Hashtable();
      hashTable.Add(&quot;1&quot;, &quot;One&quot;);
      hashTable.Add(&quot;2&quot;, 2);
      hashTable.Add(&quot;3&quot;, mylist1);
      hashTable.Add(&quot;4&quot;, mylist2);
      
      foreach(string key in hashTable.Keys)
      {
         Console.WriteLine(String.Format(&quot;{0}: {1}&quot;, key, hashTable[key]));
      }
  }
  </code></pre>
  <p>If I want to maintain the insertion order, List seems to be the right data structure. I am thinking of <code>new List&lt;Tuple&lt;string, var&gt;&gt;</code>. But my values can be of any data type.</p>
  <p>So I am looking for a data structure that can maintain insertion order and allow different datatypes for the values (like an Hashtable). How can I achieve this in C#?</p>
  <p>Should I use a <a href="https://stackoverflow.com/questions/2722767/order-preserving-data-structures-in-c-sharp">dictionary data structure that preserves the order</a> instead?</p>