Home  |  Delphi .net Home  |  System.Collections.Stack  |  GetEnumerator Method
  
GetEnumerator  
Method  
Gets an enumerator to allow reading the elements of the current Stack
Stack Class
System.Collections NameSpace
CF1.  Function GetEnumerator : IEnumerator;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns an IEnumerator object that allows the contents of the current Stack to be read.
 
A call to MoveNext must be performed before a value can be read from the enumerator - the starting position is before the first element.
References
IEnumerator
Microsoft MSDN Links
System.Collections
System.Collections.Stack
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
Geting all elements from a Stack
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Collections;

var
  MyStack    : System.Collections.Stack;
  Enumerator : IEnumerator;

begin
  // Create our Stack
  MyStack := Stack.Create;

  // Add entries to the Stack
  MyStack.Push('First');
  MyStack.Push('Second');
  MyStack.Push('Third');

  // Display the Stack
  Enumerator := MyStack.GetEnumerator;
  while enumerator.MoveNext do
    Console.WriteLine(Enumerator.Current.ToString);

  Console.Readline;
end.
   Third
   Second
   First
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author