473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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.
Jul 21 '05 #1
4 1404
BCM <BC*@email.none> wrote:
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...ary/en-us/cpre
f/html/frlrfsystemcollectionshashtableclassitemtopic.asp


In what way is it obtuse?

<quote>
When setting this property, if the specified key already exists in the
Hashtable, the value is replaced; otherwise, a new element is created
</quote>

Seems pretty clear to me.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
BCM
It's obutuse primarily because the Item property doesn't appear as an
option using intellisense.

Jon Skeet [C# MVP] wrote:
BCM <BC*@email.none> wrote:
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...ary/en-us/cpre
f/html/frlrfsystemcollectionshashtableclassitemtopic.asp

In what way is it obtuse?

<quote>
When setting this property, if the specified key already exists in the
Hashtable, the value is replaced; otherwise, a new element is created
</quote>

Seems pretty clear to me.

Jul 21 '05 #3
BCM <BC*@email.none> wrote:
It's obutuse primarily because the Item property doesn't appear as an
option using intellisense.


And yet the documentation clearly states:

<quote>
In C#, this property is the indexer for the Hashtable class.
</quote>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
BCM
Ahhh... so the notation is something like...

ht[key] = DateTime.Now;

OK. Thanks.

Jon Skeet [C# MVP] wrote:
BCM <BC*@email.none> wrote:
It's obutuse primarily because the Item property doesn't appear as an
option using intellisense.

And yet the documentation clearly states:

<quote>
In C#, this property is the indexer for the Hashtable class.
</quote>

Jul 21 '05 #5

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

Similar topics

2
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...
3
by: nzanella | last post by:
Hello, I cannot seem to find this in the MSDN documentation: what I would like to ask is whether the System.Collections.Hashtable.Add should throw an exception or replace the old value when an...
4
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...
4
by: Mark S. | last post by:
Much to my surprised the code below compiled and ran. I just don't know enough about threading to know for sure if this is too good to be true. I'm attempting to isolate the Hashtable lock to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.