IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesC#  Print This     

String Concatenation (C# and Delphi Cross Reference Guide)

By Mike Prestwood

C# versus Delphi: A side by side comparison between C# and Delphi.

 
Operators
 

A language symbol used for assignment, comparison, computational, or as a logical.

String Concatenation

[Other Languages] 
C#:  "String Concatenation" +

C# performs implicit casting of numbers to strings. To concatenate two strings, a string to an integer, or a string to a floating point number, use the + operator. For example, to convert a floating point number to a string just concatenate an empty string to the number as in "" + 3.2.

Alternatively, you can use the System.Text.StringBuilder class which frequently but not always provides faster code.

Syntax Example:
String FirstName;
String LastName;
Int16 Age;
FirstName = "Mike";
LastName = "Prestwood";
Age = 43;
Console.WriteLine(FirstName + " " + LastName + " is " + Age + ".");
  
//Implicit casting of numbers.
//
//This fails:
//MessageBox.Show(3.3);
//
//This works:
MessageBox.Show("" + 3.3); 
Delphi:  "String Concatenation" +

Use the + operator to concatenate two strings. Use IntToStr to convert an integer to a string and FloatToStr to convert a floating point number to a string.

Syntax Example:
var 
  FirstName : String; 
  LastName : String;
begin 
  FirstName := 'Mike'; 
  LastName := 'Prestwood';
  ShowMessage('Full name: ' + FirstName + ' ' + LastName);
  
  ShowMessage(FloatToStr(3.2));
end;












Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]