how to insert apostrophe in delphi string
To insert an apostrophe in a Delphi string, you can use two consecutive apostrophes. Here's an example:
var
myString: string;
begin
myString := 'I''m Delphi'; // Inserting an apostrophe in the string
ShowMessage(myString);
end;
In the above example, the string 'I''m Delphi'
will be displayed as I'm Delphi
when the ShowMessage
function is called.
This technique is used to escape the apostrophe character and include it as part of the string literal. By using two consecutive apostrophes, Delphi treats the second apostrophe as a literal character and not as the end of the string.