C# Escape Unescape

Input
Output
0 characters0 escaped

C# Escape Sequences Reference

CharacterC# EscapeUnicodeDescription
"\"\u0022Double quote
'\'\u0027Single quote
\\\\u005CBackslash
newline\n\u000ALine feed
tab\t\u0009Horizontal tab
carriage return\r\u000DCarriage return
null\0\u0000Null character
vertical tab\v\u000BVertical tab
Information

What is C# String Escaping?

C# string escaping is the process of adding backslashes before special characters in C# string literals to ensure they are interpreted correctly by the C# compiler. This is essential for .NET development when working with strings that contain quotes, backslashes, or control characters.

Why C# string escaping is important:

  • Prevents compilation errors when string literals contain quote characters that would otherwise terminate the string
  • Allows inclusion of control characters like newlines, tabs, and null characters in string literals
  • Essential for creating properly formatted C# code when generating code programmatically
  • Required for handling Windows file paths that contain backslash characters
  • Necessary for regex patterns and other strings that contain backslash sequences in .NET applications
  • Supports Unicode character representation using \uXXXX and \xXXXX escape sequences

C# supports several escape sequences including \" for double quotes, \' for single quotes, \\ for backslashes, \n for newlines, \t for tabs, \0 for null characters, and \uXXXX for Unicode characters. C# also supports verbatim strings (@"...") which disable escape sequence processing. Our tool handles all standard C# escape sequences for regular string literals.