NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Hashtable Class

Represents a collection of associated keys and values that are organized based on the hash code of the key.

Object
   Hashtable

[Visual Basic]
Public Class Hashtable
   Implements IDictionary, ICollection, IEnumerable, ISerializable, _
   IDeserializationEventListener, ICloneable
[C#]
public class Hashtable : IDictionary, ICollection, IEnumerable,
   ISerializable, IDeserializationEventListener, ICloneable
[C++]
public __gc class Hashtable : public IDictionary, ICollection,
   IEnumerable, ISerializable, IDeserializationEventListener,
   ICloneable
[JScript]
public class Hashtable implements IDictionary, ICollection,
   IEnumerable, ISerializable, IDeserializationEventListener,
   ICloneable

Remarks

The objects used as keys in a Hashtable must implement or inherit the GetHashCode and Equals methods. If key equality is simply reference equality, the inherited implementation of these methods would suffice. Furthermore, these methods must produce the same results when called with the same parameters while the key exists in the Hashtable. Key objects must be immutable, as long as they are used as keys in the Hashtable.

When an entry is added to the Hashtable, the entry is placed into a bucket based on the hashcode of the key. Subsequent lookups of the key will use the hashcode of the key to search only in one particular bucket, thus substantially reducing the number of key comparisons required to find an entry.

A Hashtable 's maximum load factor determines the maximum ratio of entries to buckets. Smaller load factors cause faster average lookup times at the cost of increased memory consumption. The default maximum load factor of 1.0 generally provides the best balance between speed and size. A different maximum load factor can also be specified when the Hashtable is instantiated.

As entries are added to a Hashtable, the Hashtable 's actual load factor increases. When the actual load factor reaches the maximum load factor, the number of buckets in the Hashtable is automatically increased to the smallest prime number that is larger than twice the current number of Hashtable buckets.

Each key object in the Hashtable must provide its own hash function, which can be accessed by calling GetHash. However, any object implementing IHashCodeProvider can be passed to a Hashtable constructor, and that hash function would be used for all objects in the table.

Requirements

Namespace: System.Collections

Assembly: mscorlib.dll

See Also

Hashtable Members | System.Collections Namespace | IDictionary | Dictionary | IHashCodeProvider | GetHashCode | Equals