Hashtable Constructor (IHashCodeProvider, IComparer)
Creates an empty Hashtable with the default initial capacity and using the default load factor, the specified hash code provider and the specified comparer.
[Visual Basic] Public Sub New( _ ByVal hcp As IHashCodeProvider, _ ByVal comparer As IComparer _ ) [C#] public Hashtable( IHashCodeProvider hcp, IComparer comparer ); [C++] public: Hashtable( IHashCodeProvider* hcp, IComparer* comparer ); [JScript] public function Hashtable( hcp : IHashCodeProvider, comparer : IComparer );
- The IHashCodeProvider that supplies the hash codes for all keys in the Hashtable.
A null reference (Nothing in Visual Basic) to use the default hash code provider, which is each key's implementation of Object.GetHashCode.
- The IComparer to use to determine whether two keys are equal.
A null reference (Nothing in Visual Basic) to use the default comparer, which is each key's implementation of Object.Equals.
A hashtable's capacity is used to calculate the optimal number of hashtable buckets based on the load factor. The default initial capacity is zero. 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. 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 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 custom hash code provider and the custom comparer enable such scenarios as doing lookups with case-insensitive strings.
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