Name
Hashtable Class
Namespace
System.Collections
Createable
Yes
Description
A Hashtable object represents a collection of values (of type Object) that are indexed by objects called keys (also of type Object). We can also think of a hash table as containing key/value pairs.
Identification of the location of elements in a hash table is done using a hashing function. Simply put, a hashing function is a function that assigns a location in the hash table to each element, based on the element’s value. This is not the place to go into any detail about hashing. It is worth mentioning that hash tables can be very efficient structures for storing and retrieving elements. However, there is no “best approach” to defining hashing functions, and so only experimentation can determine whether this particular implementation of a hash table is efficient in any given case.
Note that the Hashtable class is more flexible than the Collection class of the Microsoft.VisualBasic namespace.
Hashtable class members marked with a plus sign (+) are discussed in detail in their own entries.
Public Shared Method
Synchronized |
Public Instance Properties
Count + |
IsFixedSize |
IsReadOnly |
IsSynchronized |
Item + |
Keys + |
SyncRoot |
Values + |
Public Instance Methods
Add + |
Clear + |
Clone |
Contains |
ContainsKey + |
ContainsValue + |
CopyTo + |
Equals |
GetEnumerator |
GetHashCode |
GetObjectData |
GetType |
OnDeserialization |
Remove + |
ToString |
Example
The following example illustrates most of the members that we will discuss:
Private Sub DoHashtable( ) Dim i As Integer Dim s( ...
Get VB.NET Language in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.