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
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 lineThe 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: 17What is the escape character \t used for?
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!"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\CSharpTo 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 →