How To Modify An Element in the Dictionary Class?

Discussion in 'Software' started by Xarzu, Aug 18, 2012.

  1. Xarzu

    Xarzu Private E-2

    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);
     
  2. PC-XT

    PC-XT Master Sergeant

    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
     
  3. Xarzu

    Xarzu Private E-2


MajorGeeks.Com Menu

Downloads 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 \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

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