How To Modify An Element in the Dictionary Class?
===============================
C# has this cool Dictionary class that you can use like a Hash Table. Is there a way of changing the value of an indexed element without resorting to removing it like this?
int value = runningcount[city];
runningcount.Remove(city);
runningcount.Add(city, ++value);
and, by the way, how do I change my avatar here?
How To Modify An Element in the Dictionary Class?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Akkiraju IvaturiRank #474 · 5.2K pointsPosted Aug 18, 2012, 9:30 PM EDT
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.
But, do let me know if you can change your avatar... Even I am facing the same challenge... :) Thanks...
William Thompson145 pointsPosted Aug 18, 2012, 9:59 PM EDT
Akkiraju IvaturiRank #474 · 5.2K pointsPosted Aug 19, 2012, 5:59 PM EDT