C# Hashtable Hashtable(Int32)

Description

Hashtable Hashtable(Int32) initializes a new, empty instance of the Hashtable class using the specified initial capacity, and the default load factor, hash code provider, and comparer.

Syntax

Hashtable.Hashtable(Int32) has the following syntax.


public Hashtable(
  int capacity
)

Parameters

Hashtable.Hashtable(Int32) has the following parameters.

  • capacity - The approximate number of elements that the Hashtable object can initially contain.

Example


using System.Collections;
public class SamplesHashtable
{/*w  w w  . ja va 2s  .  c o m*/

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


    }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack