ALERT

[LAST CHANCE] Data Layer: Modern Business, Defined

Escape Sequence

Definition - What does Escape Sequence mean?

In C#, an escape sequence refers to a combination of characters beginning with a back slash (\) followed by letters or digits. Escape sequences represent non-printable and special characters in character and literal strings. As such, they allow users to communicate with a display device or printer by sending non-graphical control characters to specify actions like question marks and carriage returns.

An escape sequence is used when writing sections of code, like preprocessor definitions, to specify continuation characters, so that multiple lines of code are considered as a single line by the compiler. Regular expressions that help perform sophisticated string search operations use escape sequences to locate substrings within a large string. By enabling quoted strings, escape sequences may be used to create output files containing text template tags and files.

Techopedia explains Escape Sequence

An escape sequence contains more than one character but functions as a single character because there is no letter to textually represent the escaped character. The compiler converts the sequence of characters into a single escaped character in the compiled program. For example, the compiler converts \n in the source code into a single character (code 10), which represents the line feed in the compiled program.

The following is a list of defined C# escape sequences with corresponding representations:

  • \’ Single quotation mark used for character literals
  • \” Double quotation mark used for string literals
  • \\ Backslash used for file path
  • \? Question mark
  • \a Alert
  • \b Backspace
  • \f Form feed
  • \n New line
  • \r Carriage return
  • \t Horizontal tab
  • \v Vertical tab
  • \0 Null
  • \u Unicode escape sequence for a character with a hex value
  • \x Unicode hexadecimal escape sequence - similar to \u but with variable length
  • \U Unicode escape sequence used for surrogate pairs
This definition was written in the context of C#

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
"Techopedia" on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Resources
The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.