MajorGeeks Support Forums

Go Back   MajorGeeks Support Forums > ----------= PC, Desktop and Laptop Support =---------- > Software
Register FAQ Members List Calendar Casino Mark Forums Read

Software Software such as operating systems like Windows XP, Windows Vista, Windows 7 etc., or specific programs.


Reply
 
Thread Tools Display Modes
  #1  
Old 08-18-12, 18:55
Xarzu's Avatar
Xarzu Xarzu is offline
Private E-2
 
Join Date: Jan 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default How To Modify An Element in the Dictionary Class?

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?
Code:
               int value = runningcount[city];
               runningcount.Remove(city);
               runningcount.Add(city, ++value);
Reply With Quote
Sponsored links
  #2  
Old 08-18-12, 21:57
PC-XT's Avatar
PC-XT PC-XT is offline
Master Sergeant
 
Join Date: Oct 2007
Location: on a farm
Posts: 645
Thanks: 27
Thanked 80 Times in 74 Posts
Default Re: How To Modify An Element in the Dictionary Class?

I haven't tried this, but according to http://msdn.microsoft.com/en-us/library/9tee9ht2.aspx you can probably use
Code:
runningcount[city]++;
Note
Quote:
The C# language uses the this keyword to define the indexers instead of implementing the Item property.
__________________
I.think(code);
I.eat(code.spaghetti);
Reply With Quote
  #3  
Old 08-22-12, 20:53
Xarzu's Avatar
Xarzu Xarzu is offline
Private E-2
 
Join Date: Jan 2008
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Default Re: How To Modify An Element in the Dictionary Class?

Sweet.

I have a follow-up question to post in another thread.

Here:

http://forums.majorgeeks.com/showthr...41#post1764541
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
modify the modify date on a file? maxdamage Software 2 01-10-12 15:26
Heaviest Element Known to Man evilfantasy The Lounge 11 03-03-09 12:05
table element within a textarea be0 Software 9 07-25-08 11:47
XML Newbie Has Element Error babochka Software 0 03-28-05 16:40
java applet "Class <class name> not found" jmlady Software 0 06-16-04 14:25


All times are GMT -5. The time now is 08:58.

MajorGeeks.Com Menu

MajorGeeks.Com \ All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ NEW! PC Games \ System Tools \ Macintosh \ Demonews.Com \ Top Downloads

MajorGeeks.Com \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds


Powered by vBulletin® Version 3.8.4
Copyright © 2009 vBulletin Solutions, Inc. All rights reserved.
Ad Management by RedTyger