Iterating through a SortedList

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to change the values in a SortedList, I tried doing a
foreach but it doesn't let me modify the DictionaryEntry.
So How do I go about changing the values of a SortedList as I loop through it?


Thanks
 
rgarf,

If you want to change the values of a list while enumerating through it,
you can not use the foreach statement on the list itself.

Rather, get the keys (using the Keys property) and cycle through that,
getting/setting/changing the value as you see fit for the keys.

Hope this helps.
 

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