System.SysUtils.TStringHelper.QuotedString
Delphi
function QuotedString: string; overload;
function QuotedString(const QuoteChar: Char): string; overload;
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.SysUtils.pas | System.SysUtils | TStringHelper |
Description
QuotedString doubles all the occurrences of a character and also adds it to the edges of the string.
This method is overloaded:
- If the
QuoteChar
parameter is given, the method doubles all the occurrences of the letter specified in the parameter and also adds it to the edges of the string. Then, this method returns a new instance of the string. - If a parameter is not given, the method adds apostrophes to the beginning and end of the string. Then, this method returns a new instance of the string.
Example
The following code adds apostrophes at the edges of the string and, afterwards, doubles all the occurrences of the letter specified in the parameter:
var
myString: string;
begin
myString := 'This function illustrates the functionality of the QuotedString method.';
myString := myString.QuotedString;
myString := myString.QuotedString('f');
writeln(myString);
readln;
end.