Create Hashtable with the initial capacity and load factor in CSharp

Description

The following code shows how to create Hashtable with the initial capacity and load factor.

Example


using System;// w w w . j ava  2s .  c  o m
using System.Collections;
using System.Globalization;

public class SamplesHashtable
{
    public static void Main()
    {
        Hashtable myHT1 = new Hashtable(3, (float).8);
        myHT1.Add("FIRST", "Hello");
        myHT1.Add("SECOND", "World");
        myHT1.Add("THIRD", "!");

        foreach (string firstName in myHT1.Keys)
        {
            Console.WriteLine("{0} {1}", firstName, myHT1[firstName]);
        } 
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary