Possible Duplicate:
How do I get the nth element from a Dictionary?
I must get the key name from a dictionary.
How do I get the nth element from a Dictionary? The remedy is not .
Dictionary<string, string> ListDegree= new Dictionary<string,int>();
ListDegree.Add( 'ali', 49);
ListDegree.Add( 'veli', 50);
I want to get the “ali” with index. The following code get the value “324”.What can I do it ?
int i=-1;
foreach (var item in ListDegree)
{
i++;
}
if (i == -1)
mf.txtLog.AppendText("Error: \"Code = 1\"");
else
mf.txtLog.AppendText("Error: \""+ListDegree[ListDegree.Keys.ToList()
[i]].ToString()+"\"");
*EDIT*
*EDIT 2*
As @tomfanning said, Dictionary does not provide guarantees on ordering, so my solution is a fake solution, and doesn’t make sense.