String Formatting

The String class has a static Format() function that you use to format strings similar to the Format() function in the Delphi RTL. The type of formatting it uses is called composite formatting. The commonly used version of the overloaded String.Format() function takes a format string and values that it applies to the format string. The format string consists of fixed text and indexed placeholders.

The simplest form of String.Format() is declared as

Format(format: System.String; arg0: System.Object);

which would be used as

S :=  System.String.Format('You are {0} years old', System.Object(age));

with age being an integer variable. The following code illustrates the more common use, which takes an array of arguments to fill the ...

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.