Delphi for .NET FCL Examples Reference
| StringEnumerator | namespace |
| System.Collections.Specialized |
Declaration
StringEnumerator = class;
Description
Supports a simple iteration over a StringCollection.
Example
program System_Collections_Specialized_StringEnumerator; {$APPTYPE CONSOLE} {$AUTOBOX ON} uses System.Collections, System.Collections.Specialized; type SamplesStringEnumerator = class public class procedure Main; end; { SamplesStringEnumerator } class procedure SamplesStringEnumerator.Main; type TArrayOfString = array of string; var myEnumerator: StringEnumerator; myArr: TArrayOfString; myCol: StringCollection; begin myCol := StringCollection.Create; myArr := TArrayOfString.Create ('red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'); myCol.AddRange(myArr); myEnumerator := myCol.GetEnumerator; while myEnumerator.MoveNext do begin Console.WriteLine('{0}', myEnumerator.Current); end; Console.WriteLine; myEnumerator.Reset; if myEnumerator.MoveNext then Console.WriteLine('The first element is {0}.', myEnumerator.Current); end; //test program begin SamplesStringEnumerator.Main; end. |
Example output
red orange yellow green blue indigo violet The first element is red.
Looking for Delphi for .NET demos / source code samples? Look no further, Delphi for .NET FCL Examples Reference is what you are searching for!

