473,320 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Iterating through a SortedList

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
Nov 16 '05 #1
1 7739
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"rgarf" <rg***@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
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

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: gerrod | last post by:
Hi - Does anyone know a way to created a SortedList (in the System.Collections namespace) that will sort on VALUES instead of KEYS... ? The scenario is this - I have a SortedList containing...
6
by: Jose Jarabo | last post by:
Hello, thanks in advance for any and all replies. I am not sure how to categorize this, either a bug or something else but here is my problem. I am testing with 2 elements on a sorted list. If...
1
by: rgarf | last post by:
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...
2
by: Pekka | last post by:
Could somebody say why the piece of code below does not work? My purpose is to renumber keys in a SortedList (after removal of an item) so that the keys would always contain an unbroken sequence of...
2
by: KrippZ | last post by:
Hello I'm having some problems with a a sortedList in C#. My set is as follows: I have a sortedList as a class variable (DataList) I inisiate it in my constructor with DataList = new SortedList()....
2
by: Prez | last post by:
I started writing .net code yesterday and I am grasping it well enough. I have a few questions about SortedLists. I am using managed C++ if that makes any difference. Of the examples I...
4
by: SHEBERT | last post by:
Here is an example of a SortedList that works as a datasource to the ComboBox and a generic SortedList<that does not works as a datasource to the ComboBox. Why? If I use List and generic List<>,...
1
by: raylopez99 | last post by:
I seem to get name collision between the Generic collection SortedList and C++.NET Framework collection SortedList. How to resolve? Here are the libraries that seem to clash:...
6
by: n3tx | last post by:
Hi! I have a problem with sortedlist, i guess i dont understand how it works. I have a method called GetPublishingPlaces that returns an IList<PublishingPlace> (ex. contains 11 rows) I want...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.