Combine Strings
var
FullName: string;
begin
// Combine first and last name with a space in between using +
FullName := 'John' + ' ' + 'Doe';
// Display the full name
ShowMessage(FullName); // Output: John Doe
end;
Functions: chr, ord, length, upcase, uppercase, lowercase
var
ch: Char;
s: string;
begin
// Chr: convert ASCII value to character
ch := Chr(65); // ASCII 65 is 'A'
ShowMessage(ch); // Output: A
// Ord: convert character to ASCII value
ShowMessage(IntToStr(Ord('A'))); // Output: 65
// Length: count how many characters are in the string
s := 'Delphi';
ShowMessage(IntToStr(Length(s))); // Output: 6
// UpperCase and LowerCase: change letter case
ShowMessage(UpperCase(s)); // Output: DELPHI
ShowMessage(LowerCase(s)); // Output: delphi
end;
Difference between char and string
var
c: Char;
s: String;
begin
s := 'Hello'; // String = collection of characters
c := s[1]; // Char = single character, get the first one
// Display first character
ShowMessage(c); // Output: H
end;