Jump to content
View in the app

A better way to browse. Learn more.

Obsidian Forum Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How To Modify An Element in the Dictionary Class?

Featured Replies

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);

I have no idea why you're using that horrible proprietary rip-off of Java (which I also don't have too many kind words for) when even Microsoft themselves have ditched it in favour of a return to C++, but that's just me being a language snob. But I would recommend you focus on learning Python and C++ instead. Between those two languages you've got a super powerful toolset for tackling pretty much any problem, and as an added benefit, you can embed them in each other so you can use both at once to solve a single problem. Obviously Python's strength is scripting and rapid prototyping, while C++'s strength is power, ubiquity, and performance.

 

Anyway the answer is yes.

 

runningcount[city] = runningcount[city] + 1;

 

BTW: the Dictionary class isn't like a hash table, it is a hash table.

Edited by Krezack

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.