String Interpolation
A free lesson from Swipe Coding · C#, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
C# has a very convenient feature called "string interpolation". By placing a $ symbol right before the opening quotation mark, you can drop curly braces { } directly into your text, and whatever is inside them gets calculated and inserted into the output automatically.
Console.WriteLine($"5 plus 3 is {5 + 3}");
// Output:
// 5 plus 3 is 8You are not limited to math — you can put almost any expression inside the curly braces, and C# will convert the result to text for you automatically. Soon, once you learn about variables, you will use interpolation constantly to weave their values straight into your output.
Console.WriteLine($"Today is day {1}, and tomorrow is day {1 + 1}.");
// Output:
// Today is day 1, and tomorrow is day 2.To create an interpolated string in C#, you place a ____ symbol directly before the opening quotation mark.
Because { and } now have a special meaning inside an interpolated string, you need to double them (using {{ and }}) if you actually want to print a literal curly brace.
Console.WriteLine($"{{Score}}: {100}");
// Output:
// {Score}: 100What does this line output?
Console.WriteLine($"Total: {10 + 5}");An interpolated string in C# must start with a $ symbol before the opening quotation mark.
String interpolation is usually the cleanest way to combine fixed text with calculated values, and most C# developers reach for it by default instead of gluing pieces of text together by hand.
Output
10 questions · pass with 60% — just like in the app.
What happens automatically after Console.WriteLine("Hi"); outputs its text?
Console.Write() automatically adds a line break at the end, just like Console.WriteLine().
The escape character ____ produces a line break in the middle of a piece of text.
What does this code output?
Console.Write("A ");
Console.WriteLine("test");\t produces a tab that helps align text into columns.
To output a quotation mark directly inside a string, you write ____.
Why do you have to write \\ to output a single backslash?
To create an interpolated string, you place a ____ symbol directly before the opening quotation mark.
What does Console.WriteLine($"Total: {10 + 5}"); output?
To print a literal curly brace inside an interpolated string, you write it as {{ or }}.
Keep your streak going in Swipe Coding
Swipe through every level of C# on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →