Home  |  Delphi .net Home  |  System.Collections.Queue  |  GetEnumerator Method
GetEnumerator  
Method  
Gets an enumerator to allow reading the elements of the current Queue
Queue 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 Queue 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.Queue
 
 
Geting all elements from an Queue
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Collections;

var
  MyQueue    : System.Collections.Queue;
  Enumerator : IEnumerator;

begin
  // Create our queue
  MyQueue := Queue.Create;

  // Add entries to the queue
  MyQueue.EnQueue('First');
  MyQueue.EnQueue('Second');
  MyQueue.Enqueue('Third');

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

  Console.Readline;
end.
Show full unit code
  First
  Second
  Third
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author