C# Tutorial: Strings
String creation, interpolation, formatting, and common string methods in C#.
Working with text
`string` in C# is a reference type, but it behaves like a value type — it is immutable. Every operation that seems to modify a string actually creates a new one.
For heavy string building, use `StringBuilder` to avoid creating many intermediate strings.
What you'll learn in this C# strings tutorial
This interactive C# tutorial has 8 hands-on exercises. Estimated time: 18 minutes.
- String basics — Strings are immutable sequences of characters in double quotes.
- String interpolation — `$"text {expression}"` interpolates values directly into the string.
- String methods — C# strings have many useful methods.
- Substring and slicing — `Substring(start, length)` extracts part of a string.
- Split and Join — `Split` breaks a string into an array. `String.Join` combines an array.
- String comparison — `==` compares string values. `string.Compare` gives ordering.
- Format strings — `string.Format` with format specifiers controls number formatting.
- StringBuilder — `StringBuilder` is efficient for building strings in loops.
C# Strings concepts covered
- Working with text