All lessons

Working with Text

7 min · C#

Join strings, measure them, and format text with String tools.

C# · Working with Text0/5 cleared

Enemy 1 of 5

Strings and concatenation

Text in C# is stored as a string, and two strings can be joined together (concatenated) with the same + operator you use for adding numbers. C# figures out from the types on either side of + whether you mean "add these numbers" or "glue this text together".

Strings in C# are immutable, meaning once created, a string's contents never change in place — an operation like greeting + name always produces a brand new string rather than modifying greeting itself. That's why you either print the result directly or assign it to a new variable.

You
Packet Wolf

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: Hello, Ada