mscorlib(4.0.0.0) API with additions
System.Collections.Hashtable Class Reference

Represents a collection of key/value pairs that are organized based on the hash code of the key.To browse the .NET Framework source code for this type, see the Reference Source. More...

Inheritance diagram for System.Collections.Hashtable:
[legend]
Collaboration diagram for System.Collections.Hashtable:
[legend]

Public Member Functions

 Hashtable ()
 Initializes a new, empty instance of the T:System.Collections.Hashtable class using the default initial capacity, load factor, hash code provider, and comparer. More...
 
 Hashtable (int capacity)
 Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity, and the default load factor, hash code provider, and comparer. More...
 
 Hashtable (int capacity, float loadFactor)
 Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity and load factor, and the default hash code provider and comparer. More...
 
 Hashtable (int capacity, float loadFactor, IHashCodeProvider hcp, IComparer comparer)
 Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity, load factor, hash code provider, and comparer. More...
 
 Hashtable (int capacity, float loadFactor, IEqualityComparer equalityComparer)
 Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity, load factor, and T:System.Collections.IEqualityComparer object. More...
 
 Hashtable (IHashCodeProvider hcp, IComparer comparer)
 Initializes a new, empty instance of the T:System.Collections.Hashtable class using the default initial capacity and load factor, and the specified hash code provider and comparer. More...
 
 Hashtable (IEqualityComparer equalityComparer)
 Initializes a new, empty instance of the T:System.Collections.Hashtable class using the default initial capacity and load factor, and the specified T:System.Collections.IEqualityComparer object. More...
 
 Hashtable (int capacity, IHashCodeProvider hcp, IComparer comparer)
 Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity, hash code provider, comparer, and the default load factor. More...
 
 Hashtable (int capacity, IEqualityComparer equalityComparer)
 Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity and T:System.Collections.IEqualityComparer, and the default load factor. More...
 
 Hashtable (IDictionary d)
 Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to the new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the default load factor, hash code provider, and comparer. More...
 
 Hashtable (IDictionary d, float loadFactor)
 Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to the new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the specified load factor, and the default hash code provider and comparer. More...
 
 Hashtable (IDictionary d, IHashCodeProvider hcp, IComparer comparer)
 Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to the new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the default load factor, and the specified hash code provider and comparer. This API is obsolete. For an alternative, see M:System.Collections.Hashtable.::ctor(System.Collections.IDictionary,System.Collections.IEqualityComparer). More...
 
 Hashtable (IDictionary d, IEqualityComparer equalityComparer)
 Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to a new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the default load factor and the specified T:System.Collections.IEqualityComparer object. More...
 
 Hashtable??? (IDictionary d, float loadFactor, IHashCodeProvider hcp, IComparer comparer)
 Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to the new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the specified load factor, hash code provider, and comparer. More...
 
 Hashtable??? (IDictionary d, float loadFactor, IEqualityComparer equalityComparer)
 Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to the new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the specified load factor and T:System.Collections.IEqualityComparer object. More...
 
virtual void Add (object key, object value)
 Adds an element with the specified key and value into the T:System.Collections.Hashtable. More...
 
virtual void Clear ()
 Removes all elements from the T:System.Collections.Hashtable. More...
 
virtual object Clone ()
 Creates a shallow copy of the T:System.Collections.Hashtable. More...
 
virtual bool Contains (object key)
 Determines whether the T:System.Collections.Hashtable contains a specific key. More...
 
virtual bool ContainsKey (object key)
 Determines whether the T:System.Collections.Hashtable contains a specific key. More...
 
virtual bool ContainsValue (object value)
 Determines whether the T:System.Collections.Hashtable contains a specific value. More...
 
virtual void CopyTo (Array array, int arrayIndex)
 Copies the T:System.Collections.Hashtable elements to a one-dimensional T:System.Array instance at the specified index. More...
 
virtual IDictionaryEnumerator GetEnumerator ()
 Returns an T:System.Collections.IDictionaryEnumerator that iterates through the T:System.Collections.Hashtable. More...
 
virtual void Remove (object key)
 Removes the element with the specified key from the T:System.Collections.Hashtable. More...
 
virtual void GetObjectData (SerializationInfo info, StreamingContext context)
 Implements the T:System.Runtime.Serialization.ISerializable interface and returns the data needed to serialize the T:System.Collections.Hashtable. More...
 
virtual void OnDeserialization (object sender)
 Implements the T:System.Runtime.Serialization.ISerializable interface and raises the deserialization event when the deserialization is complete. More...
 

Static Public Member Functions

static Hashtable Synchronized (Hashtable table)
 Returns a synchronized (thread-safe) wrapper for the T:System.Collections.Hashtable. More...
 

Public Attributes

virtual bool IsReadOnly => false
 Gets a value indicating whether the T:System.Collections.Hashtable is read-only. More...
 
virtual bool IsFixedSize => false
 Gets a value indicating whether the T:System.Collections.Hashtable has a fixed size. More...
 
virtual bool IsSynchronized => false
 Gets a value indicating whether access to the T:System.Collections.Hashtable is synchronized (thread safe). More...
 
virtual int Count => count
 Gets the number of key/value pairs contained in the T:System.Collections.Hashtable. More...
 

Protected Member Functions

 Hashtable (SerializationInfo info, StreamingContext context)
 Initializes a new, empty instance of the T:System.Collections.Hashtable class that is serializable using the specified T:System.Runtime.Serialization.SerializationInfo and T:System.Runtime.Serialization.StreamingContext objects. More...
 
virtual int GetHash (object key)
 Returns the hash code for the specified key. More...
 
virtual bool KeyEquals (object item, object key)
 Compares a specific T:System.Object with a specific key in the T:System.Collections.Hashtable. More...
 

Protected Attributes

IEqualityComparer EqualityComparer => _keycomparer
 Gets the T:System.Collections.IEqualityComparer to use for the T:System.Collections.Hashtable. More...
 

Properties

IHashCodeProvider hcp [get, set]
 Gets or sets the object that can dispense hash codes. More...
 
IComparer comparer [get, set]
 Gets or sets the T:System.Collections.IComparer to use for the T:System.Collections.Hashtable. More...
 
virtual object this[object key] [get, set]
 Gets or sets the value associated with the specified key. More...
 
virtual ICollection Keys [get]
 Gets an T:System.Collections.ICollection containing the keys in the T:System.Collections.Hashtable. More...
 
virtual ICollection Values [get]
 Gets an T:System.Collections.ICollection containing the values in the T:System.Collections.Hashtable. More...
 
virtual object SyncRoot [get]
 Gets an object that can be used to synchronize access to the T:System.Collections.Hashtable. More...
 
- Properties inherited from System.Collections.IDictionary
object this[object key] [get, set]
 Gets or sets the element with the specified key. More...
 
ICollection Keys [get]
 Gets an T:System.Collections.ICollection object containing the keys of the T:System.Collections.IDictionary object. More...
 
ICollection Values [get]
 Gets an T:System.Collections.ICollection object containing the values in the T:System.Collections.IDictionary object. More...
 
bool IsReadOnly [get]
 Gets a value indicating whether the T:System.Collections.IDictionary object is read-only. More...
 
bool IsFixedSize [get]
 Gets a value indicating whether the T:System.Collections.IDictionary object has a fixed size. More...
 
- Properties inherited from System.Collections.ICollection
int Count [get]
 Gets the number of elements contained in the T:System.Collections.ICollection. More...
 
object SyncRoot [get]
 Gets an object that can be used to synchronize access to the T:System.Collections.ICollection. More...
 
bool IsSynchronized [get]
 Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (thread safe). More...
 

Detailed Description

Represents a collection of key/value pairs that are organized based on the hash code of the key.To browse the .NET Framework source code for this type, see the Reference Source.

Definition at line 17 of file Hashtable.cs.

Constructor & Destructor Documentation

◆ Hashtable() [1/14]

System.Collections.Hashtable.Hashtable ( )

Initializes a new, empty instance of the T:System.Collections.Hashtable class using the default initial capacity, load factor, hash code provider, and comparer.

Definition at line 665 of file Hashtable.cs.

◆ Hashtable() [2/14]

System.Collections.Hashtable.Hashtable ( int  capacity)

Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity, and the default load factor, hash code provider, and comparer.

Parameters
capacityThe approximate number of elements that the T:System.Collections.Hashtable object can initially contain.
Exceptions
T:System.ArgumentOutOfRangeExceptioncapacity is less than zero.

Definition at line 674 of file Hashtable.cs.

◆ Hashtable() [3/14]

System.Collections.Hashtable.Hashtable ( int  capacity,
float  loadFactor 
)

Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity and load factor, and the default hash code provider and comparer.

Parameters
capacityThe approximate number of elements that the T:System.Collections.Hashtable object can initially contain.
loadFactorA number in the range from 0.1 through 1.0 that is multiplied by the default value which provides the best performance. The result is the maximum ratio of elements to buckets.
Exceptions
T:System.ArgumentOutOfRangeExceptioncapacity is less than zero.-or- loadFactor is less than 0.1.-or- loadFactor is greater than 1.0.
T:System.ArgumentExceptioncapacity is causing an overflow.

Definition at line 688 of file Hashtable.cs.

◆ Hashtable() [4/14]

System.Collections.Hashtable.Hashtable ( int  capacity,
float  loadFactor,
IHashCodeProvider  hcp,
IComparer  comparer 
)

Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity, load factor, hash code provider, and comparer.

Parameters
capacityThe approximate number of elements that the T:System.Collections.Hashtable object can initially contain.
loadFactorA number in the range from 0.1 through 1.0 that is multiplied by the default value which provides the best performance. The result is the maximum ratio of elements to buckets.
hcpThe T:System.Collections.IHashCodeProvider object that supplies the hash codes for all keys in the T:System.Collections.Hashtable.-or- null to use the default hash code provider, which is each key's implementation of M:System.Object.GetHashCode.
comparerThe T:System.Collections.IComparer object to use to determine whether two keys are equal.-or- null to use the default comparer, which is each key's implementation of M:System.Object.Equals(System.Object).
Exceptions
T:System.ArgumentOutOfRangeExceptioncapacity is less than zero.-or- loadFactor is less than 0.1.-or- loadFactor is greater than 1.0.

Definition at line 722 of file Hashtable.cs.

◆ Hashtable() [5/14]

System.Collections.Hashtable.Hashtable ( int  capacity,
float  loadFactor,
IEqualityComparer  equalityComparer 
)

Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity, load factor, and T:System.Collections.IEqualityComparer object.

Parameters
capacityThe approximate number of elements that the T:System.Collections.Hashtable object can initially contain.
loadFactorA number in the range from 0.1 through 1.0 that is multiplied by the default value which provides the best performance. The result is the maximum ratio of elements to buckets.
equalityComparerThe T:System.Collections.IEqualityComparer object that defines the hash code provider and the comparer to use with the T:System.Collections.Hashtable.-or- null to use the default hash code provider and the default comparer. The default hash code provider is each key's implementation of M:System.Object.GetHashCode and the default comparer is each key's implementation of M:System.Object.Equals(System.Object).
Exceptions
T:System.ArgumentOutOfRangeExceptioncapacity is less than zero.-or- loadFactor is less than 0.1.-or- loadFactor is greater than 1.0.

Definition at line 744 of file Hashtable.cs.

◆ Hashtable() [6/14]

System.Collections.Hashtable.Hashtable ( IHashCodeProvider  hcp,
IComparer  comparer 
)

Initializes a new, empty instance of the T:System.Collections.Hashtable class using the default initial capacity and load factor, and the specified hash code provider and comparer.

Parameters
hcpThe T:System.Collections.IHashCodeProvider object that supplies the hash codes for all keys in the T:System.Collections.Hashtable object.-or- null to use the default hash code provider, which is each key's implementation of M:System.Object.GetHashCode.
comparerThe T:System.Collections.IComparer object to use to determine whether two keys are equal.-or- null to use the default comparer, which is each key's implementation of M:System.Object.Equals(System.Object).

Definition at line 756 of file Hashtable.cs.

◆ Hashtable() [7/14]

System.Collections.Hashtable.Hashtable ( IEqualityComparer  equalityComparer)

Initializes a new, empty instance of the T:System.Collections.Hashtable class using the default initial capacity and load factor, and the specified T:System.Collections.IEqualityComparer object.

Parameters
equalityComparerThe T:System.Collections.IEqualityComparer object that defines the hash code provider and the comparer to use with the T:System.Collections.Hashtable object.-or- null to use the default hash code provider and the default comparer. The default hash code provider is each key's implementation of M:System.Object.GetHashCode and the default comparer is each key's implementation of M:System.Object.Equals(System.Object).

Definition at line 764 of file Hashtable.cs.

◆ Hashtable() [8/14]

System.Collections.Hashtable.Hashtable ( int  capacity,
IHashCodeProvider  hcp,
IComparer  comparer 
)

Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity, hash code provider, comparer, and the default load factor.

Parameters
capacityThe approximate number of elements that the T:System.Collections.Hashtable object can initially contain.
hcpThe T:System.Collections.IHashCodeProvider object that supplies the hash codes for all keys in the T:System.Collections.Hashtable.-or- null to use the default hash code provider, which is each key's implementation of M:System.Object.GetHashCode.
comparerThe T:System.Collections.IComparer object to use to determine whether two keys are equal.-or- null to use the default comparer, which is each key's implementation of M:System.Object.Equals(System.Object).
Exceptions
T:System.ArgumentOutOfRangeExceptioncapacity is less than zero.

Definition at line 778 of file Hashtable.cs.

◆ Hashtable() [9/14]

System.Collections.Hashtable.Hashtable ( int  capacity,
IEqualityComparer  equalityComparer 
)

Initializes a new, empty instance of the T:System.Collections.Hashtable class using the specified initial capacity and T:System.Collections.IEqualityComparer, and the default load factor.

Parameters
capacityThe approximate number of elements that the T:System.Collections.Hashtable object can initially contain.
equalityComparerThe T:System.Collections.IEqualityComparer object that defines the hash code provider and the comparer to use with the T:System.Collections.Hashtable.-or- null to use the default hash code provider and the default comparer. The default hash code provider is each key's implementation of M:System.Object.GetHashCode and the default comparer is each key's implementation of M:System.Object.Equals(System.Object).
Exceptions
T:System.ArgumentOutOfRangeExceptioncapacity is less than zero.

Definition at line 789 of file Hashtable.cs.

◆ Hashtable() [10/14]

System.Collections.Hashtable.Hashtable ( IDictionary  d)

Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to the new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the default load factor, hash code provider, and comparer.

Parameters
dThe T:System.Collections.IDictionary object to copy to a new T:System.Collections.Hashtable object.
Exceptions
T:System.ArgumentNullExceptiond is null.

Definition at line 798 of file Hashtable.cs.

◆ Hashtable() [11/14]

System.Collections.Hashtable.Hashtable ( IDictionary  d,
float  loadFactor 
)

Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to the new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the specified load factor, and the default hash code provider and comparer.

Parameters
dThe T:System.Collections.IDictionary object to copy to a new T:System.Collections.Hashtable object.
loadFactorA number in the range from 0.1 through 1.0 that is multiplied by the default value which provides the best performance. The result is the maximum ratio of elements to buckets.
Exceptions
T:System.ArgumentNullExceptiond is null.
T:System.ArgumentOutOfRangeExceptionloadFactor is less than 0.1.-or- loadFactor is greater than 1.0.

Definition at line 811 of file Hashtable.cs.

◆ Hashtable() [12/14]

System.Collections.Hashtable.Hashtable ( IDictionary  d,
IHashCodeProvider  hcp,
IComparer  comparer 
)

Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to the new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the default load factor, and the specified hash code provider and comparer. This API is obsolete. For an alternative, see M:System.Collections.Hashtable.::ctor(System.Collections.IDictionary,System.Collections.IEqualityComparer).

Parameters
dThe T:System.Collections.IDictionary object to copy to a new T:System.Collections.Hashtable object.
hcpThe T:System.Collections.IHashCodeProvider object that supplies the hash codes for all keys in the T:System.Collections.Hashtable.-or- null to use the default hash code provider, which is each key's implementation of M:System.Object.GetHashCode.
comparerThe T:System.Collections.IComparer object to use to determine whether two keys are equal.-or- null to use the default comparer, which is each key's implementation of M:System.Object.Equals(System.Object).
Exceptions
T:System.ArgumentNullExceptiond is null.

Definition at line 825 of file Hashtable.cs.

◆ Hashtable() [13/14]

System.Collections.Hashtable.Hashtable ( IDictionary  d,
IEqualityComparer  equalityComparer 
)

Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to a new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the default load factor and the specified T:System.Collections.IEqualityComparer object.

Parameters
dThe T:System.Collections.IDictionary object to copy to a new T:System.Collections.Hashtable object.
equalityComparerThe T:System.Collections.IEqualityComparer object that defines the hash code provider and the comparer to use with the T:System.Collections.Hashtable.-or- null to use the default hash code provider and the default comparer. The default hash code provider is each key's implementation of M:System.Object.GetHashCode and the default comparer is each key's implementation of M:System.Object.Equals(System.Object).
Exceptions
T:System.ArgumentNullExceptiond is null.

Definition at line 836 of file Hashtable.cs.

◆ Hashtable() [14/14]

System.Collections.Hashtable.Hashtable ( SerializationInfo  info,
StreamingContext  context 
)
protected

Initializes a new, empty instance of the T:System.Collections.Hashtable class that is serializable using the specified T:System.Runtime.Serialization.SerializationInfo and T:System.Runtime.Serialization.StreamingContext objects.

Parameters
infoA T:System.Runtime.Serialization.SerializationInfo object containing the information required to serialize the T:System.Collections.Hashtable object.
contextA T:System.Runtime.Serialization.StreamingContext object containing the source and destination of the serialized stream associated with the T:System.Collections.Hashtable.
Exceptions
T:System.ArgumentNullExceptioninfo is null.

Definition at line 897 of file Hashtable.cs.

Member Function Documentation

◆ Add()

virtual void System.Collections.Hashtable.Add ( object  key,
object  value 
)
virtual

Adds an element with the specified key and value into the T:System.Collections.Hashtable.

Parameters
keyThe key of the element to add.
valueThe value of the element to add. The value can be null.
Exceptions
T:System.ArgumentNullExceptionkey is null.
T:System.ArgumentExceptionAn element with the same key already exists in the T:System.Collections.Hashtable.
T:System.NotSupportedExceptionThe T:System.Collections.Hashtable is read-only.-or- The T:System.Collections.Hashtable has a fixed size.

Implements System.Collections.IDictionary.

Definition at line 916 of file Hashtable.cs.

◆ Clear()

virtual void System.Collections.Hashtable.Clear ( )
virtual

Removes all elements from the T:System.Collections.Hashtable.

Exceptions
T:System.NotSupportedExceptionThe T:System.Collections.Hashtable is read-only.

Implements System.Collections.IDictionary.

Definition at line 924 of file Hashtable.cs.

◆ Clone()

virtual object System.Collections.Hashtable.Clone ( )
virtual

Creates a shallow copy of the T:System.Collections.Hashtable.

Returns
A shallow copy of the T:System.Collections.Hashtable.

Implements System.ICloneable.

Definition at line 946 of file Hashtable.cs.

◆ Contains()

virtual bool System.Collections.Hashtable.Contains ( object  key)
virtual

Determines whether the T:System.Collections.Hashtable contains a specific key.

Parameters
keyThe key to locate in the T:System.Collections.Hashtable.
Returns
true if the T:System.Collections.Hashtable contains an element with the specified key; otherwise, false.
Exceptions
T:System.ArgumentNullExceptionkey is null.

Implements System.Collections.IDictionary.

Definition at line 972 of file Hashtable.cs.

◆ ContainsKey()

virtual bool System.Collections.Hashtable.ContainsKey ( object  key)
virtual

Determines whether the T:System.Collections.Hashtable contains a specific key.

Parameters
keyThe key to locate in the T:System.Collections.Hashtable.
Returns
true if the T:System.Collections.Hashtable contains an element with the specified key; otherwise, false.
Exceptions
T:System.ArgumentNullExceptionkey is null.

Definition at line 983 of file Hashtable.cs.

◆ ContainsValue()

virtual bool System.Collections.Hashtable.ContainsValue ( object  value)
virtual

Determines whether the T:System.Collections.Hashtable contains a specific value.

Parameters
valueThe value to locate in the T:System.Collections.Hashtable. The value can be null.
Returns
true if the T:System.Collections.Hashtable contains an element with the specified value ; otherwise, false.

Definition at line 1017 of file Hashtable.cs.

◆ CopyTo()

virtual void System.Collections.Hashtable.CopyTo ( Array  array,
int  arrayIndex 
)
virtual

Copies the T:System.Collections.Hashtable elements to a one-dimensional T:System.Array instance at the specified index.

Parameters
arrayThe one-dimensional T:System.Array that is the destination of the T:System.Collections.DictionaryEntry objects copied from T:System.Collections.Hashtable. The T:System.Array must have zero-based indexing.
arrayIndexThe zero-based index in array at which copying begins.
Exceptions
T:System.ArgumentNullExceptionarray is null.
T:System.ArgumentOutOfRangeExceptionarrayIndex is less than zero.
T:System.ArgumentExceptionarray is multidimensional.-or- The number of elements in the source T:System.Collections.Hashtable is greater than the available space from arrayIndex to the end of the destination array .
T:System.InvalidCastExceptionThe type of the source T:System.Collections.Hashtable cannot be cast automatically to the type of the destination array .

Implements System.Collections.ICollection.

Definition at line 1084 of file Hashtable.cs.

◆ GetEnumerator()

virtual IDictionaryEnumerator System.Collections.Hashtable.GetEnumerator ( )
virtual

Returns an T:System.Collections.IDictionaryEnumerator that iterates through the T:System.Collections.Hashtable.

Returns
An T:System.Collections.IDictionaryEnumerator for the T:System.Collections.Hashtable.

Implements System.Collections.IDictionary.

Definition at line 1184 of file Hashtable.cs.

◆ GetHash()

virtual int System.Collections.Hashtable.GetHash ( object  key)
protectedvirtual

Returns the hash code for the specified key.

Parameters
keyThe T:System.Object for which a hash code is to be returned.
Returns
The hash code for key .
Exceptions
T:System.NullReferenceExceptionkey is null.

Definition at line 1194 of file Hashtable.cs.

◆ GetObjectData()

virtual void System.Collections.Hashtable.GetObjectData ( SerializationInfo  info,
StreamingContext  context 
)
virtual

Implements the T:System.Runtime.Serialization.ISerializable interface and returns the data needed to serialize the T:System.Collections.Hashtable.

Parameters
infoA T:System.Runtime.Serialization.SerializationInfo object containing the information required to serialize the T:System.Collections.Hashtable.
contextA T:System.Runtime.Serialization.StreamingContext object containing the source and destination of the serialized stream associated with the T:System.Collections.Hashtable.
Exceptions
T:System.ArgumentNullExceptioninfo is null.
T:System.InvalidOperationExceptionThe collection was modified.

Implements System.Runtime.Serialization.ISerializable.

Definition at line 1413 of file Hashtable.cs.

◆ Hashtable???() [1/2]

System.Collections.Hashtable.Hashtable??? ( IDictionary  d,
float  loadFactor,
IHashCodeProvider  hcp,
IComparer  comparer 
)

Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to the new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the specified load factor, hash code provider, and comparer.

Parameters
dThe T:System.Collections.IDictionary object to copy to a new T:System.Collections.Hashtable object.
loadFactorA number in the range from 0.1 through 1.0 that is multiplied by the default value which provides the best performance. The result is the maximum ratio of elements to buckets.
hcpThe T:System.Collections.IHashCodeProvider object that supplies the hash codes for all keys in the T:System.Collections.Hashtable.-or- null to use the default hash code provider, which is each key's implementation of M:System.Object.GetHashCode.
comparerThe T:System.Collections.IComparer object to use to determine whether two keys are equal.-or- null to use the default comparer, which is each key's implementation of M:System.Object.Equals(System.Object).
Exceptions
T:System.ArgumentNullExceptiond is null.
T:System.ArgumentOutOfRangeExceptionloadFactor is less than 0.1.-or- loadFactor is greater than 1.0.

Definition at line 854 of file Hashtable.cs.

◆ Hashtable???() [2/2]

System.Collections.Hashtable.Hashtable??? ( IDictionary  d,
float  loadFactor,
IEqualityComparer  equalityComparer 
)

Initializes a new instance of the T:System.Collections.Hashtable class by copying the elements from the specified dictionary to the new T:System.Collections.Hashtable object. The new T:System.Collections.Hashtable object has an initial capacity equal to the number of elements copied, and uses the specified load factor and T:System.Collections.IEqualityComparer object.

Parameters
dThe T:System.Collections.IDictionary object to copy to a new T:System.Collections.Hashtable object.
loadFactorA number in the range from 0.1 through 1.0 that is multiplied by the default value which provides the best performance. The result is the maximum ratio of elements to buckets.
equalityComparerThe T:System.Collections.IEqualityComparer object that defines the hash code provider and the comparer to use with the T:System.Collections.Hashtable.-or- null to use the default hash code provider and the default comparer. The default hash code provider is each key's implementation of M:System.Object.GetHashCode and the default comparer is each key's implementation of M:System.Object.Equals(System.Object).
Exceptions
T:System.ArgumentNullExceptiond is null.
T:System.ArgumentOutOfRangeExceptionloadFactor is less than 0.1.-or- loadFactor is greater than 1.0.

Definition at line 878 of file Hashtable.cs.

◆ KeyEquals()

virtual bool System.Collections.Hashtable.KeyEquals ( object  item,
object  key 
)
protectedvirtual

Compares a specific T:System.Object with a specific key in the T:System.Collections.Hashtable.

Parameters
itemThe T:System.Object to compare with key .
keyThe key in the T:System.Collections.Hashtable to compare with item .
Returns
true if item and key are equal; otherwise, false.
Exceptions
T:System.ArgumentNullExceptionitem is null.-or- key is null.

Definition at line 1211 of file Hashtable.cs.

◆ OnDeserialization()

virtual void System.Collections.Hashtable.OnDeserialization ( object  sender)
virtual

Implements the T:System.Runtime.Serialization.ISerializable interface and raises the deserialization event when the deserialization is complete.

Parameters
senderThe source of the deserialization event.
Exceptions
T:System.Runtime.Serialization.SerializationExceptionThe T:System.Runtime.Serialization.SerializationInfo object associated with the current T:System.Collections.Hashtable is invalid.

Implements System.Runtime.Serialization.IDeserializationCallback.

Definition at line 1457 of file Hashtable.cs.

◆ Remove()

virtual void System.Collections.Hashtable.Remove ( object  key)
virtual

Removes the element with the specified key from the T:System.Collections.Hashtable.

Parameters
keyThe key of the element to remove.
Exceptions
T:System.ArgumentNullExceptionkey is null.
T:System.NotSupportedExceptionThe T:System.Collections.Hashtable is read-only.-or- The T:System.Collections.Hashtable has a fixed size.

Implements System.Collections.IDictionary.

Definition at line 1349 of file Hashtable.cs.

◆ Synchronized()

static Hashtable System.Collections.Hashtable.Synchronized ( Hashtable  table)
static

Returns a synchronized (thread-safe) wrapper for the T:System.Collections.Hashtable.

Parameters
tableThe T:System.Collections.Hashtable to synchronize.
Returns
A synchronized (thread-safe) wrapper for the T:System.Collections.Hashtable.
Exceptions
T:System.ArgumentNullExceptiontable is null.

Definition at line 1397 of file Hashtable.cs.

Member Data Documentation

◆ Count

virtual int System.Collections.Hashtable.Count => count

Gets the number of key/value pairs contained in the T:System.Collections.Hashtable.

Returns
The number of key/value pairs contained in the T:System.Collections.Hashtable.

Definition at line 658 of file Hashtable.cs.

◆ EqualityComparer

IEqualityComparer System.Collections.Hashtable.EqualityComparer => _keycomparer
protected

Gets the T:System.Collections.IEqualityComparer to use for the T:System.Collections.Hashtable.

Returns
The T:System.Collections.IEqualityComparer to use for the T:System.Collections.Hashtable.
Exceptions
T:System.ArgumentExceptionThe property is set to a value, but the hash table was created using an T:System.Collections.IHashCodeProvider and an T:System.Collections.IComparer.

Definition at line 543 of file Hashtable.cs.

◆ IsFixedSize

virtual bool System.Collections.Hashtable.IsFixedSize => false

Gets a value indicating whether the T:System.Collections.Hashtable has a fixed size.

Returns
true if the T:System.Collections.Hashtable has a fixed size; otherwise, false. The default is false.

Definition at line 607 of file Hashtable.cs.

◆ IsReadOnly

virtual bool System.Collections.Hashtable.IsReadOnly => false

Gets a value indicating whether the T:System.Collections.Hashtable is read-only.

Returns
true if the T:System.Collections.Hashtable is read-only; otherwise, false. The default is false.

Definition at line 602 of file Hashtable.cs.

◆ IsSynchronized

virtual bool System.Collections.Hashtable.IsSynchronized => false

Gets a value indicating whether access to the T:System.Collections.Hashtable is synchronized (thread safe).

Returns
true if access to the T:System.Collections.Hashtable is synchronized (thread safe); otherwise, false. The default is false.

Definition at line 612 of file Hashtable.cs.

Property Documentation

◆ comparer

IComparer System.Collections.Hashtable.comparer
getsetprotected

Gets or sets the T:System.Collections.IComparer to use for the T:System.Collections.Hashtable.

Returns
The T:System.Collections.IComparer to use for the T:System.Collections.Hashtable.
Exceptions
T:System.ArgumentExceptionThe property is set to a value, but the hash table was created using an T:System.Collections.IEqualityComparer.

Definition at line 510 of file Hashtable.cs.

◆ hcp

IHashCodeProvider System.Collections.Hashtable.hcp
getsetprotected

Gets or sets the object that can dispense hash codes.

Returns
The object that can dispense hash codes.
Exceptions
T:System.ArgumentExceptionThe property is set to a value, but the hash table was created using an T:System.Collections.IEqualityComparer.

Definition at line 475 of file Hashtable.cs.

◆ Keys

virtual ICollection System.Collections.Hashtable.Keys
get

Gets an T:System.Collections.ICollection containing the keys in the T:System.Collections.Hashtable.

Returns
An T:System.Collections.ICollection containing the keys in the T:System.Collections.Hashtable.

Definition at line 617 of file Hashtable.cs.

◆ SyncRoot

virtual object System.Collections.Hashtable.SyncRoot
get

Gets an object that can be used to synchronize access to the T:System.Collections.Hashtable.

Returns
An object that can be used to synchronize access to the T:System.Collections.Hashtable.

Definition at line 645 of file Hashtable.cs.

◆ this[object key]

virtual object System.Collections.Hashtable.this[object key]
getset

Gets or sets the value associated with the specified key.

Parameters
keyThe key whose value to get or set.
Returns
The value associated with the specified key. If the specified key is not found, attempting to get it returns null, and attempting to set it creates a new element using the specified key.
Exceptions
T:System.ArgumentNullExceptionkey is null.
T:System.NotSupportedExceptionThe property is set and the T:System.Collections.Hashtable is read-only.-or- The property is set, key does not exist in the collection, and the T:System.Collections.Hashtable has a fixed size.

Definition at line 552 of file Hashtable.cs.

◆ Values

virtual ICollection System.Collections.Hashtable.Values
get

Gets an T:System.Collections.ICollection containing the values in the T:System.Collections.Hashtable.

Returns
An T:System.Collections.ICollection containing the values in the T:System.Collections.Hashtable.

Definition at line 631 of file Hashtable.cs.


The documentation for this class was generated from the following file: