Description |
Returns an IEnumerator object that allows the contents of the current ArrayList to be read. Optionally, you may specify that the enumerator works with only Count elements from StartIndex.
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.ArrayList
|
|
|
Geting all elements from an ArrayList |
program Project1;
{$APPTYPE CONSOLE}
uses
System.Collections;
var
List : System.Collections.ArrayList;
Enumerator : IEnumerator;
begin
// Create our array list object
List := ArrayList.Create;
// Fill it
List.Add('Hello');
List.Add('from');
List.Add('Delphi');
List.Add('Basics');
// Get the enumerator for the whole ArrayList
Enumerator := List.GetEnumerator;
// Display the array using the enumerator
// Note : we must call MoveNext before we can see the 1st element
while Enumerator.MoveNext do
Console.WriteLine(Enumerator.Current.ToString);
Console.Readline;
end.
| Show full unit code | Hello
from
Delphi
Basics
| | Getting just a subset of ArrayList elements | program Project1;
{$APPTYPE CONSOLE}
uses
System.Collections;
var
List : System.Collections.ArrayList;
Enumerator : IEnumerator;
begin
// Create our array list object
List := ArrayList.Create;
// Fill it
List.Add('Hello');
List.Add('from');
List.Add('Delphi');
List.Add('Basics');
// Get the enumerator for the just the middle 2 elements
Enumerator := List.GetEnumerator(1, 2);
// Display the array using the enumerator
// Note : we must call MoveNext before we can see the 1st element
while Enumerator.MoveNext do
Console.WriteLine(Enumerator.Current.ToString);
Console.Readline;
end.
| Show full unit code | from
Delphi
|
|
|
|