views:

3844

answers:

2

Hi,

I work on .net 2.0 and would like to do the following.

I want to update the value in the Dictionary for a specific key. I will be putting it in a for loop so that the value gets updated for all the keys passed in.

Any idea?

+13  A: 

Just point to the dictionary at given key and assign a new value:

myDictionary[myKey] = myNewValue;

HTH! mt

m.bagattini
A: 

It s possible by accessing the key as index

for example

if the dictionary is declared as Dictionary list = new Dictionary();

then you can set the value for the key "test" as follows

list["test"] = list["test"] + 1;

now the value for the key will get incremented by 1.

Cheers..!

Amit
yes. .........
Ray