O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required