C# Stack GetEnumerator

Description

Stack GetEnumerator returns an IEnumerator for the Stack.

Syntax

Stack.GetEnumerator has the following syntax.


public virtual IEnumerator GetEnumerator()

Returns

Stack.GetEnumerator method returns An IEnumerator for the Stack.

Example


using System;//w  w w.  ja  v a  2s.c  o  m
using System.Collections;
public class SamplesStack  {

    public static void Main()  {
       Stack mySourceQ = new Stack();
       mySourceQ.Push( "A" );
       mySourceQ.Push( "B" );
       mySourceQ.Push( "C" );

      IEnumerator e = mySourceQ.GetEnumerator();
      while (e.MoveNext())
      {
          Object obj = e.Current;
          Console.WriteLine(obj);
      }
   }
}      

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack