1. Home
  2. Computing & Technology
  3. Delphi Programming
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!

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.