C# StringDictionary GetEnumerator

Description

StringDictionary GetEnumerator returns an enumerator that iterates through the string dictionary.

Syntax

StringDictionary.GetEnumerator has the following syntax.


public virtual IEnumerator GetEnumerator()

Returns

StringDictionary.GetEnumerator method returns An IEnumerator that iterates through the string dictionary.

Example

The following code example enumerates the elements of a StringDictionary.


//from   www  .j a v  a  2s . c  o m
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" );

      IEnumerator myEnumerator = myCol.GetEnumerator();
      DictionaryEntry de;
      while ( myEnumerator.MoveNext() )  {
         de = (DictionaryEntry) myEnumerator.Current;
         Console.WriteLine( "   {0,-25} {1}", de.Key, de.Value );
      }

   }
}

The code above generates the following result.





















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




BitVector32
HybridDictionary
ListDictionary
OrderedDictionary
StringCollection
StringDictionary
StringEnumerator