Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Output · Lesson 17 of 27

Escape Characters

A free lesson from Swipe Coding · C#, level 2 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
Some characters need a little help to show up in your text. 🔡

Sometimes you want to output something that cannot simply be typed as-is — for example a line break in the middle of a sentence, or a quotation mark. For this, C# has "escape characters": a backslash (\) followed by a letter that carries a special meaning.

Console.WriteLine("First line\nSecond line");

// Output:
// First line
// Second line
\n produces a line break — in the middle of a single WriteLine() call.
Fill in the blank

The escape character ____ produces a line break in the middle of a piece of text.

The escape character \t produces a tab — a larger, even amount of spacing. This lets you roughly line up text into columns.

Console.WriteLine("Name:\tMax");
Console.WriteLine("Age:\t17");

// Output:
// Name:   Max
// Age:    17
\t makes "Max" and "17" line up roughly underneath each other, even though "Name:" and "Age:" have different lengths.
Quick check

What is the escape character \t used for?

🤖
This trick lets a quotation mark exist peacefully inside a string. 💬

If you try to place a regular quotation mark in the middle of a piece of text, there is a problem: C# would think the string ends right there. The fix is \" — an "escaped" quotation mark that is treated as plain text instead of the end of the string.

Console.WriteLine("She said: \"C# is awesome!\"");

// Output:
// She said: "C# is awesome!"
Without the backslashes before the inner quotation marks, the compiler would end the string too early and report an error.
🤖
Even backslashes need their own special trick to print. ⚙️

And what if you actually want to output a backslash itself — for example in a file path? Since a single backslash normally starts an escape character, you have to double it: \\.

Console.WriteLine("The path is: C:\\Projects\\CSharp");

// Output:
// The path is: C:\Projects\CSharp
Each \\ in the code produces exactly one real backslash in the output.
True or false

To output a single backslash, you must write \\ in the code rather than just \.

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 →