title: Iterate through IList<Hashtable> by index in ASP.NET MVC
body: <p>I am having some trouble iterating through a <code>IList&lt;Hashtable&gt;</code>. I am trying to iterate it by index i.e.:</p>
  <p>I have an <code>IList&lt;Hashtable&gt;</code> with 3 different <code>Hashtable</code>s in it. I want to <code>foreach</code> each one by <code>IList</code>'s index. In example:</p>
  <p>I want first to <code>foreach</code> all <code>KeyValuePair</code>s in <code>Hashtable</code> in <code>IList</code> index=0. When finished do some stuff and then <code>foreach</code> all <code>KeyValuePair</code>s in <code>Hashtable</code> in <code>IList</code> index=1 and so on until all <code>Hashtable</code>s are iterated through. Currently the code is as follows:</p>
  <p>variable <code>data</code> is an <code>IList&lt;Hashtable&gt;</code> with 3 <code>Hashtable</code>s in it.</p>
  <pre class="lang-cs prettyprint-override"><code>foreach (Hashtable rowData in data[index])
  {
      some code here...
  }
  </code></pre>
  <p>I get the following error:</p>
  <blockquote>
  <p>Unable to cast object of type 'System.Collections.DictionaryEntry' to type 'System.Collections.Hashtable'.</p>
  </blockquote>