Description |
Builds an array of characters from the current string.
Optionally, the Start index in the string, and the Count of characters can be specified.
|
| Notes | Very Important : Methods in .Net treat strings as starting at 0, unlike traditional Delphi where they started at 1.
|
|
Microsoft MSDN Links |
system
system.String
|
|
|
A simple example |
program Project1;
{$APPTYPE CONSOLE}
var
strA : String;
charArray : Array of Char;
len : Integer;
begin
strA := 'Hello';
charArray := strA.ToCharArray;
len := Length(charArray);
Console.WriteLine('strA = ' + strA);
Console.WriteLine('charArray = ' + charArray);
Console.WriteLine('charArray length = {0}', len.ToString);
Console.ReadLine;
end.
| Show full unit code | strA = Hello
charArray = Hello
charArray length = 5
| | Using only a section of the string | program Project1;
{$APPTYPE CONSOLE}
var
strA : String;
charArray : Array of Char;
len : Integer;
begin
strA := '0123456789';
charArray := strA.ToCharArray(6, 2);
len := Length(charArray);
Console.WriteLine('strA = ' + strA);
Console.WriteLine('charArray = ' + charArray);
Console.WriteLine('charArray length = {0}', len.ToString);
Console.ReadLine;
end.
| Show full unit code | strA = 0123456789
charArray = 67
charArray length = 2
|
|
|
|