C# Hashtable Clear

Description

Hashtable Clear removes all elements from the Hashtable.

Syntax

Hashtable.Clear has the following syntax.


public virtual void Clear()

Returns

Hashtable.Clear method returns

Example

The following example shows how to clear the values of the Hashtable.


//from ww  w . j  a v  a 2 s.c  o  m
using System;
using System.Collections;
public class SamplesHashtable  {

    public static void Main()  {
       Hashtable myHT = new Hashtable();
       myHT.Add( "one", "1" );

       Console.WriteLine(myHT.Count );
       myHT.Clear();
       Console.WriteLine(myHT.Count );
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack