C# String Concatenation

String Concatenation

The + operator can be used between strings to combine them. This is called concatenation:

Example

string firstName = "John ";
string lastName = "Doe";
string name = firstName + lastName;
Console.WriteLine(name);

 

Note that we have added a space after “John” to create a space between firstName and lastName on print.

Continue reading C# String Concatenation

C++ String Concatenation

String Concatenation

The + operator can be used between strings to add them together to make a new string. This is called concatenation:

Example

string firstName = "John ";
string lastName = "Doe";
string fullName = firstName + lastName;
cout << fullName;

In the example above, we added a space after firstName to create a space between John and Doe on output. However, you could also add a space with quotes (" " or ' '): Continue reading C++ String Concatenation