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.
 
Back
Top