Create Hashtable from dictionary with the specified load factor in CSharp

Description

The following code shows how to create Hashtable from dictionary with the specified load factor.

Example


//ww w. j  a v a2s  .  com
using System;
using System.Collections;
using System.Globalization;


public class SamplesHashtable
{
    public static void Main()
    {
        SortedList mySL = new SortedList();
        mySL.Add("FIRST", "Hello");
        mySL.Add("SECOND", "World");
        mySL.Add("THIRD", "!");

        Hashtable myHT1 = new Hashtable(mySL, (float).8);


        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