Hashtable: setting a value?

  • Thread starter Thread starter BCM
  • Start date Start date
B

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/d...fsystemcollectionshashtableclassitemtopic.asp

Thanks in advance.
 
BCM said:
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/default.asp?url=/library/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.
 
It's obutuse primarily because the Item property doesn't appear as an
option using intellisense.
 
BCM said:
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>
 
Back
Top