title: How do I remove element from specific place in Dictionary in C#?
body: <p>I have a "Dictionary" data base and I want to return an element from a specific location. I saw that there is "ElementAt" function but I didnt manage to use it.</p>
  
  <p>Why doesnt something like that work?</p>
  
  <pre><code>closeHash.ElementAt&lt;State&gt;(i);
  </code></pre>
  
  <p>it tells me the following error:</p>
  
  <p>Error   3   'System.Collections.Generic.Dictionary' does not contain a definition for 'ElementAt' and the best extension method overload 'System.Linq.Queryable.ElementAt(System.Linq.IQueryable, int)' has some invalid arguments</p>
  
  <p>And this code also doesnt work because closeHash[i] gives me only the index and not the actual element:</p>
  
  <pre><code>   if (closeHash.ContainsKey(i) &amp;&amp; ((State)closeHash[i]).getH() + 
  ((State)closeHash[i]).getG() &gt; checkState.getH() + checkState.getG()
  </code></pre>
  
  <p>Each element in the Dictionary is of a class "State" and checkState also is a State that has GetH and GetG Functions. I want to take out the element at the Ith position and work on it and not just remove it.</p>
  
  <p>thanks in advance!</p>
  
  <p>Greg</p>