how looping over a dictionary by loop for

  • Thread starter Thread starter skneife
  • Start date Start date
S

skneife

I need to access to a dictionary by its index like a string array.
Dictionary<string, string> tdmDx1 = new Dictionary<string, string>();
for (int item = 0; item < tdmDx1.Count; item++) {

.... how access item by its index ???

}

Sam
 
I need to access to a dictionary by its index like a string array.
Dictionary<string, string> tdmDx1 = new Dictionary<string, string>();
for (int item = 0; item < tdmDx1.Count; item++) {

   .... how access item by its index ???

}

Sam

You can't because the Dictionary class is implemented with a hashtable
so the index doesn't make much sense. Let me ask you this...what
would you want the index value of 0 to mean? That might help us
determine what kind of collection best fits your needs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top