Home  |  Delphi .net Home  |  System.Globalization.StringInfo  |  GetTextElementEnumerator Method
GetTextElementEnumerator  
Method  
Returns an enumerator for the Text elements of the given String
StringInfo Class
System.Globalization NameSpace
CF1.  Function GetTextElementEnumerator ( TextString : String; ) : TextElementEnumerator;
CF2.  Function GetTextElementEnumerator ( TextString:StringTextString : String; StartIndex : Integer; ) : TextElementEnumerator; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
The GetTextElementEnumerator method returns a TextElementEnumerator object that provides a controlled mechanism for processing the text elements in the given TextString.
 
Optionally, the string may be parsed from the given StartIndex.
Notes
Very Important : Methods in .Net treat strings as starting at 0, unlike traditional Delphi where they started at 1.
Microsoft MSDN Links
System.Globalization
System.Globalization.StringInfo
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Globalization;

var
  enumerator : System.Globalization.TextElementEnumerator;
  myString   : String;
  myText     : String;

begin
  myString := 'Hello';

  enumerator := StringInfo.GetTextElementEnumerator(myString);

  while enumerator.MoveNext do
  begin
    myText := String(enumerator.Current);
    Console.WriteLine(myText);
  end;

  Console.ReadLine;
end.
Show full unit code
  H
  e
  l
  l
  o
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author