|
-
September 27th, 2011, 08:25 AM
#1
Rename dictionary key
Hi,
Is it possible to change the key of a dictionary?
Thanks
-
September 27th, 2011, 08:51 AM
#2
Re: Rename dictionary key
What Dictionary ??? ... What Key ???
Encryption ??? What Language ????
More info needed to process....
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
September 27th, 2011, 09:13 AM
#3
Re: Rename dictionary key
I assume he is talking about the default Dictionary class:
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
-
September 27th, 2011, 10:29 AM
#4
Re: Rename dictionary key
Sorry, it's the dictionary class that contains keys and values. I have a dictionary that contains a key. I anyway retrieved values of one particular key's values, added two new keys, and added the same values to the newley added keys. But when I update the value of one key, it updates the value of the other key as well. Any idea why?
Thanks
-
September 27th, 2011, 03:41 PM
#5
Re: Rename dictionary key
Post the code that your using, so that we can see how and why...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
October 19th, 2011, 10:04 AM
#6
Re: Rename dictionary key
No, you can't rename the key of a dictionary entry directly. However, you can copy the value from the old entry to a new entry and then delete the old one. Something like this:
Code:
myDictionary.Add(preferredKeyName, myDictionary(oldKeyName))
myDictionary.Remove(oldKeyName)
-
October 22nd, 2011, 03:15 AM
#7
Re: Rename dictionary key
Never ever do that. Sorry, but my opinion is why create the dictionary in the first place then. I always have this discussion with my students. My answer is always the same. Make sure you only use what is needed. If you have to half way through your program EDIT the dictionaries, your planning is wrong. Yes, maybe there is a need for this, but in my opinion it is just edit programming ( where you keep on editing things just to keep your app going ), instead of of proper programming ( where you almost never need to edit existing objects - and your app is behaving good )
Just saying....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|