471,348 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to update a value in a Dictionary<K, V>

do i have to remove the pair and then reinsert it or can i just update the
value of the dictionary
Jun 27 '08 #1
4 5035
"amir" <am**@discussions.microsoft.comwrote:
do i have to remove the pair and then reinsert it or can i just update
the value of the dictionary
Just update it. A dictionary can only have one value stored per unique
key.

Eq.
Jun 27 '08 #2
what do you mean just update it? how do i update a value for a certain key?

"Paul E Collins" wrote:
"amir" <am**@discussions.microsoft.comwrote:
do i have to remove the pair and then reinsert it or can i just update
the value of the dictionary

Just update it. A dictionary can only have one value stored per unique
key.

Eq.
Jun 27 '08 #3
Assuming that the key is in the dictionary,

MyDictionary ["MyCertainKey"] = "Some new value...";
"amir" wrote:
what do you mean just update it? how do i update a value for a certain key?

"Paul E Collins" wrote:
"amir" <am**@discussions.microsoft.comwrote:
do i have to remove the pair and then reinsert it or can i just update
the value of the dictionary
Just update it. A dictionary can only have one value stored per unique
key.

Eq.

Jun 27 '08 #4
dictionary["KeyName"] = newValue;

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"amir" <am**@discussions.microsoft.comwrote in message
news:78**********************************@microsof t.com...
do i have to remove the pair and then reinsert it or can i just update the
value of the dictionary
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by William Stacey [MVP] | last post: by
8 posts views Thread by Brian P | last post: by
12 posts views Thread by Brett Romero | last post: by
7 posts views Thread by Andrew Robinson | last post: by
8 posts views Thread by Peter Larsen [CPH] | last post: by
reply views Thread by Ronak mishra | last post: by

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.