C# StringDictionary Clear

Description

StringDictionary Clear removes all entries from the StringDictionary.

Syntax

StringDictionary.Clear has the following syntax.


public virtual void Clear()

Returns

StringDictionary.Clear method returns

Example

The following code example demonstrates how to add and remove elements from a StringDictionary.


/*w w w.j av a 2 s  .  com*/
using System;
using System.Collections;
using System.Collections.Specialized;

public class SamplesStringDictionary  {

   public static void Main()  {
      StringDictionary myCol = new StringDictionary();
      myCol.Add( "red", "rojo" );
      myCol.Add( "green", "verde" );
      myCol.Add( "blue", "azul" );

      myCol.Remove( "green" );

      foreach ( DictionaryEntry de in myCol )
         Console.WriteLine( "   {0,-10} {1}", de.Key, de.Value );
      Console.WriteLine();
   }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections.Specialized »




BitVector32
HybridDictionary
ListDictionary
OrderedDictionary
StringCollection
StringDictionary
StringEnumerator