473,805 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hashtable: setting a value?

BCM
How do you reset a value for an existing key in a hashtable? I need to
create a collection and compare the values with another collection: when
certain parameters are met then I need to reset the value of certain
elelments in the first collection.

I would have thought that the Hashtable.Item property would do the
trick, as MSDN defines it as "Gets or sets the value associated with the
specified key". But the actual documentation is so obtuse it's just silly:

http://msdn.microsoft.com/library/de...sitemtopic.asp

Thanks in advance.
Nov 16 '05 #1
2 3338
What do you mean by "reset"?

To set a value its just something like:

Hashtable hash = new Hashtable();
....
hash[key] = newValue;

--
Adam Clauss
ca*****@tamu.ed u

"BCM" <BC*@email.none > wrote in message news:41******** @news.unc.edu.. .
How do you reset a value for an existing key in a hashtable? I need to
create a collection and compare the values with another collection: when
certain parameters are met then I need to reset the value of certain
elelments in the first collection.

I would have thought that the Hashtable.Item property would do the
trick, as MSDN defines it as "Gets or sets the value associated with the
specified key". But the actual documentation is so obtuse it's just silly:

http://msdn.microsoft.com/library/de...sitemtopic.asp

Thanks in advance.

Nov 16 '05 #2
Hi BCM,

What part of the docs you didn't get?
What do you mean by reseting the value?
If it is just to set it to null

hasttable[key] = null will do the trick for you.

If you want to remove the key/vlue pair for the item use

hasttable.Remov e(key) = null will do the trick for you.

--
HTH
Stoitcho Goutsev (100) [C# MVP]
"BCM" <BC*@email.none > wrote in message news:41******** @news.unc.edu.. .
How do you reset a value for an existing key in a hashtable? I need to
create a collection and compare the values with another collection: when
certain parameters are met then I need to reset the value of certain
elelments in the first collection.

I would have thought that the Hashtable.Item property would do the
trick, as MSDN defines it as "Gets or sets the value associated with the
specified key". But the actual documentation is so obtuse it's just silly:

http://msdn.microsoft.com/library/de...sitemtopic.asp
Thanks in advance.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7420
by: oliver.wulff | last post by:
Does there exist a class similar to a hashtable which provides a key-value pair collection. The key and the value has to be a string?
4
1427
by: BCM | last post by:
How do you reset a value for an existing key in a hashtable? I need to create a collection and compare the values with another collection: when certain parameters are met then I need to reset the value of certain elelments in the first collection. I would have thought that the Hashtable.Item property would do the trick, as MSDN defines it as "Gets or sets the value associated with the specified key". But the actual documentation is so...
4
17481
by: Vladimir C. | last post by:
Hashtable map = new Hashtable(); map = 10; map = 20; foreach(DictionaryEntry e in map) { e.Value = 100; Console.WriteLine("{0}: {1}", key, map); }
1
1037
by: Dick | last post by:
Hello, I've a hashtable. When searching I can use 'Contains' method. This returns true or false. What if I want the actual value? Must i doo a loop with a enumerator and search each key? Or is there a faster manner?
6
14674
by: max sharma | last post by:
Hi all, I am using a hashtable for my application. Its similar to word count application. How can I sort the hashtable w.r.t. the VALUE and not the KEY. The sample data of the table is given below which is sorted according the URL as in Dictionary: www.webroot.com (11) www.webshots.com (1) www.weddingprints.com (4) here, Key = URL (e.g. www.webroot.com)
6
23561
by: max sharma | last post by:
Hi all, I am using hashtable in C# with keys of type string and values of type double. I am not able to find a way to sort them by value (descending to be precise) instead of key. Can someone please help me. Thank you all in advance, Max *** Sent via Developersdex http://www.developersdex.com ***
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10613
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.