C# Hashtable Count

Description

Hashtable Count gets the number of key/value pairs contained in the Hashtable.

Syntax

Hashtable.Count has the following syntax.


public virtual int Count { get; }

Example


using System;/* w  w w  .j a v a2s .  co  m*/
using System.Collections;

class MainClass
{
    public static void Main()
    {
        Hashtable    hash = new Hashtable();
        hash.Add("A", "1");
        hash.Add("B", "2");
        hash.Add("C", "3");
        hash.Add("D", "4");
        hash.Add("E", "5");
        
        Console.WriteLine(hash.Count);

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack