Hashtable.Add Method


Hashtable.Add Method

Class

System.Collections.Hashtable

Syntax

     hashtableVariable.Add(key, value) 


key (required; any)

The key to be used to access the newly added value


value (required; any)

The new value to be added to the hashtable

Description

The Add method adds a key/value pair to the hashtable.

Usage at a Glance

  • key must be unique or a runtime error occurs. value does not need to be unique.

  • Keys are immutable. Once added, a particular key cannot be changed during the lifetime of the hashtable except by removing it through the Remove or Clear method and then adding it once again. Values associated with keys can be changed through the Item property.

  • The Item property can also be used to add new members to the hashtable.

  • To ensure that a key is unique when calling the Add method, use the ContainsKey method.

See Also

Hashtable Class, Hashtable.ContainsKey Method, Hashtable.Item Property




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net