This documentation is archived and is not being maintained.

Hashtable Constructor (IDictionary)

.NET Framework 1.1

Copies the elements from the specified dictionary to a new Hashtable with the same initial capacity as the number of elements copied and using the default load factor, the default hash code provider and the default comparer.

[Visual Basic]
Public Sub New( _
   ByVal d As IDictionary _
public Hashtable(
   IDictionary d
public: Hashtable(
   IDictionary* d
public function Hashtable(
   d : IDictionary


The IDictionary to copy to a new Hashtable.


Exception Type Condition
ArgumentNullException d is a null reference (Nothing in Visual Basic).


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. The default load factor is 1.0, which is the best balance between speed and size.

When the actual load factor reaches the 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 Hashtable. The default hash code provider is the key's implementation of Object.GetHashCode.

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

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


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Hashtable Class | Hashtable Members | System.Collections Namespace | Hashtable Constructor Overload List | IDictionary | Object.GetHashCode | Object.Equals