BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 This class is safe for multiple readers and a single writer. System.Object System.Collections.IDictionary System.ICloneable System.Runtime.Serialization.IDeserializationCallback System.Runtime.Serialization.ISerializable System.Diagnostics.DebuggerDisplay("Count={Count}") System.Diagnostics.DebuggerTypeProxy(typeof(System.Collections.CollectionDebuggerView)) System.Runtime.InteropServices.ComVisible(true)

The following example shows how to iterate over the elements of a .

[C#]

foreach (DictionaryEntry myEntry in myHashtable)

Each element is a key/value pair stored in a object. A key cannot be null, but a value can be.

The objects used as keys by a are required to override the method (or the interface) and the method (or the interface). The implementation of both methods and interfaces must handle case sensitivity the same way; otherwise, the might behave incorrectly. For example, when creating a , you must use the class (or any case-insensitive implementation) with the class (or any case-insensitive implementation).

Furthermore, these methods must produce the same results when called with the same parameters while the key exists in the . An alternative is to use a constructor with an parameter. If key equality were simply reference equality, the inherited implementation of and would suffice.

Key objects must be immutable as long as they are used as keys in the .

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

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

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

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

The capacity of a is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation.

For very large objects, you can increase the maximum capacity to 2 billion elements on a 64-bit system by setting the enabled attribute of the gcAllowVeryLargeObjects configuration element to true in the run-time environment.

The foreach statement of the C# language (For Each in Visual Basic) requires the type of each element in the collection. Since each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example:

code reference: System.Collections.Hashtable_ClassExample#01

The foreach statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection.

Because serializing and deserializing an enumerator for a can cause the elements to become reordered, it is not possible to continue enumeration without calling the method.

Because keys can be inherited and their behavior changed, their absolute uniqueness cannot be guaranteed by comparisons using the method.

Represents a collection of key/value pairs that are organized based on the hash code of the key.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  A hash table's capacity is used to calculate the optimal number of hash table buckets based on the load factor. Capacity is automatically increased as required.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the object. The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  This constructor is an O(1) operation.

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

  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  is .

  The initial capacity is set to the number of elements in the source dictionary. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the object. The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The elements of the new are sorted in the same order in which the enumerator iterates through the object.

  This constructor is an O() operation, where is the number of elements in the parameter.

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

  The object to copy to a new object.
  0
- Constructor
  2.0.0.0
  4.0.0.0

  A hash table's capacity is used to calculate the optimal number of hash table buckets based on the load factor. Capacity is automatically increased as required.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The object includes both the hash code provider and the comparer. If an is used in the constructor, the objects used as keys in the object are not required to override the and methods.

  The hash code provider dispenses hash codes for keys in the . The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The enables scenarios such as doing lookups with case-insensitive strings.

  This constructor is an O(1) operation.

  Initializes a new, empty instance of the class using the default initial capacity and load factor, and the specified object.

  The object that defines the hash code provider and the comparer to use with the object.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  < 0.

  Specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the . The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  This constructor is an O() operation, where is .

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

  The approximate number of elements that the object can initially contain.
  0
- Constructor
  2.0.0.0
  4.0.0.0

  The initial capacity is set to the number of elements in the source dictionary. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The object includes both the hash code provider and the comparer. If an is used in the constructor, the objects used as keys in the object are not required to override the and methods.

  The hash code provider dispenses hash codes for keys in the . The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The enables scenarios such as doing lookups with case-insensitive strings.

  The elements of the new are sorted in the same order in which the enumerator iterates through the object.

  This constructor is an O() operation, where is the number of elements in the parameter.

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

  The object to copy to a new object.
  The object that defines the hash code provider and the comparer to use with the .
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The initial capacity is set to the number of elements in the source dictionary. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption. A load factor of 1.0 is the best balance between speed and size.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the object. The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The elements of the new are sorted in the same order in which the enumerator iterates through the object.

  This constructor is an O() operation, where is the number of elements in the parameter.

  Initializes a new instance of the class by copying the elements from the specified dictionary to the new object. The new 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.

  The object to copy to a new object.
  A 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.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("Please use Hashtable(IEqualityComparer) instead")

  A hash table's capacity is used to calculate the optimal number of hash table buckets based on the load factor. Capacity is automatically increased as required.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the object. The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The custom hash code provider and the custom comparer enable scenarios such as doing lookups with case-insensitive strings.

  This constructor is an O(1) operation.

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

  The object that supplies the hash codes for all keys in the object.
  The object to use to determine whether two keys are equal.
  0
- Constructor
  2.0.0.0
  4.0.0.0

  Specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The object includes both the hash code provider and the comparer. If an is used in the constructor, the objects used as keys in the are not required to override the and methods.

  The hash code provider dispenses hash codes for keys in the . The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The enables scenarios such as doing lookups with case-insensitive strings.

  This constructor is an O() operation, where is the parameter.

  Initializes a new, empty instance of the class using the specified initial capacity and , and the default load factor.

  The approximate number of elements that the object can initially contain.
  The object that defines the hash code provider and the comparer to use with the .
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  Specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption. A load factor of 1.0 is the best balance between speed and size.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the . The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  This constructor is an O() operation, where is the parameter.

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

  The approximate number of elements that the object can initially contain.
  A 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.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  A hash table's capacity is used to calculate the optimal number of hash table buckets based on the load factor. Capacity is automatically increased as required.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the object. The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  This constructor is an O() operation, where is .

  Because serializing and deserializing an enumerator for a can cause the elements to become reordered, it is not possible to continue enumeration without calling the method.

  Initializes a new, empty instance of the class that is serializable using the specified and objects.

  A object containing the information required to serialize the object.
  A object containing the source and destination of the serialized stream associated with the .
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("Please use Hashtable(IDictionary, IEqualityComparer) instead")
  is .

  The initial capacity is set to the number of elements in the source dictionary. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the object. The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The custom hash code provider and the custom comparer enable scenarios such as doing lookups with case-insensitive strings.

  The elements of the new are sorted in the same order in which the enumerator iterates through the object.

  This constructor is an O() operation, where is the number of elements in the parameter.

  Initializes a new instance of the class by copying the elements from the specified dictionary to the new object. The new 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 .

  The object to copy to a new object.
  The object that supplies the hash codes for all keys in the .
  The object to use to determine whether two keys are equal.
  0
- Constructor
  2.0.0.0
  4.0.0.0

  The initial capacity is set to the number of elements in the source dictionary. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption. A load factor of 1.0 is the best balance between speed and size.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The object includes both the hash code provider and the comparer. If an is used in the constructor, the objects used as keys in the object are not required to override the and methods.

  The hash code provider dispenses hash codes for keys in the . The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The enables scenarios such as doing lookups with case-insensitive strings.

  The elements of the new are sorted in the same order in which the enumerator iterates through the object.

  This constructor is an O() operation, where is the number of elements in the parameter.

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

  The object to copy to a new object.
  A 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.
  The object that defines the hash code provider and the comparer to use with the .
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("Please use Hashtable(int, IEqualityComparer) instead")

  Specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the . The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The custom hash code provider and the custom comparer enable scenarios such as doing lookups with case-insensitive strings.

  This constructor is an O() operation, where is the parameter.

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

  The approximate number of elements that the object can initially contain.
  The object that supplies the hash codes for all keys in the .
  The object to use to determine whether two keys are equal.
  0
- Constructor
  2.0.0.0
  4.0.0.0

  Specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption. A load factor of 1.0 is the best balance between speed and size.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The object includes both the hash code provider and the comparer. If an is used in the constructor, the objects used as keys in the are not required to override the and methods.

  The hash code provider dispenses hash codes for keys in the . The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The enables scenarios such as doing lookups with case-insensitive strings.

  This constructor is an O() operation, where is the parameter.

  Initializes a new, empty instance of the class using the specified initial capacity, load factor, and object.

  The approximate number of elements that the object can initially contain.
  A 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.
  The object that defines the hash code provider and the comparer to use with the .
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("Please use Hashtable(IDictionary, float, IEqualityComparer) instead")

  The initial capacity is set to the number of elements in the source dictionary. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption. A load factor of 1.0 is the best balance between speed and size.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the object. The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The custom hash code provider and the custom comparer enable scenarios such as doing lookups with case-insensitive strings.

  The elements of the new are sorted in the same order in which the enumerator iterates through the object.

  This constructor is an O() operation, where is the number of elements in the parameter.

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

  The object to copy to a new object.
  A 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.
  The object that supplies the hash codes for all keys in the .
  The object to use to determine whether two keys are equal.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("Please use Hashtable(int, float, IEqualityComparer) instead")

  Specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. Capacity is automatically increased as required based on the load factor.

  The load factor is the maximum ratio of elements to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption. A load factor of 1.0 is the best balance between speed and size.

  When the actual load factor reaches the specified load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

  The hash code provider dispenses hash codes for keys in the . The default hash code provider is the key's implementation of .

  The comparer determines whether two keys are equal. Every key in a must be unique. The default comparer is the key's implementation of .

  The custom hash code provider and the custom comparer enable scenarios such as doing lookups with case-insensitive strings.

  This constructor is an O() operation, where is the parameter.

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

  The approximate number of elements that the object can initially contain.
  A 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.
  The object that supplies the hash codes for all keys in the .
  The object to use to determine whether two keys are equal.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  is .

  An entry with the same key already exists in the current instance.

  The current instance is read-only or has a fixed size.

  A key cannot be null, but a value can be.

  An object that has no correlation between its state and its hash code value should typically not be used as the key. For example, String objects are better than StringBuilder objects for use as keys.

  You can also use the property to add new elements by setting the value of a key that does not exist in the ; for example, myCollection["myNonexistentKey"] = myValue. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements.

  If is less than the capacity of the , this method is an O(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an O() operation, where is .

  Adds an element with the specified key and value into the .

  The key of the element to add. The value of the element to add. The value can be null. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Void The current instance is read-only.

  is set to zero, and references to other objects from elements of the collection are also released. The capacity remains unchanged.

  This method is an O() operation, where is .

  Removes all elements from the .

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object

  A shallow copy of a collection copies only the elements of the collection, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new collection point to the same objects that the references in the original collection point to.

  In contrast, a deep copy of a collection copies the elements and everything directly or indirectly referenced by the elements.

  The clone has the same count, the same capacity, the same implementation, and the same implementation as the original .

  This method is an O() operation, where is .

  Creates a shallow copy of the .

  A shallow copy of the .

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("Please use EqualityComparer property.")
  System.Collections.IComparer To be added.

  Retrieving the value of this property is an O(1) operation.

  Gets or sets the to use for the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` is .

  implements . It behaves exactly as .

  This method is an O(1) operation.

  Starting with the .NET Framework 2.0, this method uses the collection’s objects’ and methods on to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the parameter on the objects in the collection.

  Determines whether the contains a specific key.

  true if the contains an element with the specified key; otherwise, false.

  The key to locate in the . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` is .

  This method behaves exactly as .

  This method is an O(1) operation.

  Starting with the .NET Framework 2.0, this method uses the collection’s objects’ and methods on to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the parameter on the objects in the collection.

  Determines whether the contains a specific key.

  true if the contains an element with the specified key; otherwise, false.

  The key to locate in the . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  The values of the elements of the are compared to the specified value using the method.

  This method performs a linear search; therefore, this method is an O() operation, where is .

  Starting with the .NET Framework 2.0, this method uses the collection’s objects’ and methods on to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the parameter on the objects in the collection.

  Determines whether the contains a specific value.

  true if the contains an element with the specified ; otherwise, false.

  The value to locate in the . The value can be null. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` is . < 0.

  has more than one dimension.

  -or-

  > .Length - The of the current instance.

  The type of the current instance is not assignment-compatible with the type of .

  The elements are copied to the in the same order in which the enumerator iterates through the .

  To copy only the keys in the , use Hashtable.Keys.CopyTo.

  To copy only the values in the , use Hashtable.Values.CopyTo.

  This method is an O() operation, where is .

  Copies the elements to a one-dimensional instance at the specified index.

  The one-dimensional that is the destination of the objects copied from . The must have zero-based indexing. The zero-based index in at which copying begins. 0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A that specifies the number of key-and-value pairs contained in the current instance.

  Retrieving the value of this property is an O(1) operation.

  Gets the number of key/value pairs contained in the .

  0
- Property
  2.0.0.0
  4.0.0.0
  System.Collections.IEqualityComparer To be added.

  The includes both the comparer and the hash code provider. If an is used in the constructor, the objects used as keys in the are not required to override the and methods.

  Retrieving the value of this property is an O(1) operation.

  Gets the to use for the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.IDictionaryEnumerator

  [Visual Basic, C#]

  The foreach statement of the C# language (for each in Visual Basic) hides the complexity of the enumerators. Therefore, using foreach is recommended, instead of directly manipulating the enumerator.

  Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.

  Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of .

  returns the same object until either or is called. sets to the next element.

  If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns false. When the enumerator is at this position, subsequent calls to also return false. If the last call to returned false, is undefined. To set to the first element of the collection again, you can call followed by .

  An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined.

  The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

  This method is an O(1) operation.

  Because serializing and deserializing an enumerator for a can cause the elements to become reordered, it is not possible to continue enumeration without calling the method.

  Returns an that iterates through the .

  An for the .

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` is .

  If the hash table was created with a specific implementation, this method uses that hash code provider; otherwise, it uses the implementation of .

  This method is an O(1) operation.

  Returns the hash code for the specified key.

  The hash code for .

  The for which a hash code is to be returned. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  This method is an O() operation, where is .

  Implements the interface and returns the data needed to serialize the .

  A object containing the information required to serialize the . A object containing the source and destination of the serialized stream associated with the .
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("Please use EqualityComparer property.")
  System.Collections.IHashCodeProvider To be added.

  Retrieving the value of this property is an O(1) operation.

  Gets or sets the object that can dispense hash codes.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean

  if the current instance has a fixed size; otherwise, .

  A collection with a fixed size does not allow the addition or removal of elements after the collection is created, but it allows the modification of existing elements.

  A collection with a fixed size is simply a collection with a wrapper that prevents adding and removing elements; therefore, if changes are made to the underlying collection, including the addition or removal of elements, the fixed-size collection reflects those changes.

  Retrieving the value of this property is an O(1) operation.

  Gets a value indicating whether the has a fixed size.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean

  if the current instance is read-only; otherwise, .

  A collection that is read-only does not allow the addition, removal, or modification of elements after the collection is created.

  A collection that is read-only is simply a collection with a wrapper that prevents modifying the collection; therefore, if changes are made to the underlying collection, the read-only collection reflects those changes.

  Retrieving the value of this property is an O(1) operation.

  Gets a value indicating whether the is read-only.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean

  if access to the current instance is synchronized (thread-safe); otherwise, .

  A can support one writer and multiple readers concurrently. To support multiple writers, all operations must be done through the wrapper returned by the method.

  Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

  The following code example shows how to lock the collection using the during the entire enumeration:

  code reference: Classic Hashtable.IsSynchronized Example#2

  Gets a value indicating whether access to the is synchronized (thread safe).

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object `` The key whose value to get or set.

  Gets or sets the value in the current instance that is associated with the specified key.

  The value in the current instance that is associated with . If is not contained in the current instance, attempting to get it returns , and attempting to set it creates a new entry using

  .

  This property provides the ability to access a specific element in the current instance using the following notation: myCollection[key] .

  As described above.

  If this property is being set and is already contained in the current instance, the value associated with the old key is replaced.

  is .

  The property is being set and the current instance is read-only.

  The property is being set, is not contained in the current instance, and the current instance has a fixed size.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  is .

  -or-

  is .

  If the hash table was created with a specific implementation, this method uses that comparer; that is, (, ). Otherwise, it uses item.Equals(key).

  This method is an O(1) operation.

  Compares a specific with a specific key in the .

  true if and are equal; otherwise, false.

  The to compare with . The key in the to compare with . 0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.ICollection

  A containing the keys of the current instance.

  The order of the keys in the is unspecified, but it is the same order as the associated values in the returned by the method.

  The returned is not a static copy; instead, the refers back to the keys in the original . Therefore, changes to the continue to be reflected in the .

  Retrieving the value of this property is an O(1) operation.

  Gets an containing the keys in the .

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  This method is an O() operation, where is .

  Because serializing and deserializing an enumerator for a can cause the elements to become reordered, it is not possible to continue enumeration without calling the method.

  Implements the interface and raises the deserialization event when the deserialization is complete.

  The source of the deserialization event.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.MayFail)
  System.Void `` is .

  The current instance is read-only or has a fixed size.

  If the does not contain an element with the specified key, the remains unchanged. No exception is thrown.

  This method is an O(1) operation.

  Removes the element with the specified key from the .

  The key of the element to remove. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.Hashtable `` is .

  The method is thread safe for multiple readers and writers. Furthermore, the synchronized wrapper ensures that there is only one writer writing at a time.

  Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

  The following code example shows how to lock the collection using the during the entire enumeration:

  code reference: Classic Hashtable.IsSynchronized Example#2

  This method is an O(1) operation.

  Returns a synchronized (thread-safe) wrapper for the .

  A synchronized (thread-safe) wrapper for the .

  The to synchronize. 0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object

  A that can be used to synchronize access to the current instance.

  To create a synchronized version of the , use the method. However, derived classes can provide their own synchronized version of the using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object.

  Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

  The following code example shows how to lock the collection using the during the entire enumeration:

  code reference: Classic Hashtable.IsSynchronized Example#2

  Gets an object that can be used to synchronize access to the .

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.IEnumerator

  [Visual Basic, C#]

  The foreach statement of the C# language (for each in Visual Basic) hides the complexity of the enumerators. Therefore, using foreach is recommended, instead of directly manipulating the enumerator.

  Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.

  Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of .

  returns the same object until either or is called. sets to the next element.

  If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns false. When the enumerator is at this position, subsequent calls to also return false. If the last call to returned false, calling throws an exception. To set to the first element of the collection again, you can call followed by .

  An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator can be invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated.

  The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

  This method is an O(1) operation.

  Returns an enumerator that iterates through a collection.

  An that can be used to iterate through the collection.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.ICollection

  A containing the values of the current instance.

  The order of the values in the is unspecified, but it is the same order as the associated keys in the returned by the method.

  The returned is not a static copy; instead, the refers back to the values in the original . Therefore, changes to the continue to be reflected in the .

  Retrieving the value of this property is an O(1) operation.

  Gets an containing the values in the .

  0
0