Escape sequences express characters that cannot be expressed or interpreted literally. - CSharp Language Basics

CSharp examples for Language Basics:string

Introduction

An escape sequence is a backslash followed by a character with a special meaning.

Escape sequence characters

CharMeaningValue
\'Single quote 0x0027
\"Double quote 0x0022
\\Backslash 0x005C
\0Null 0x0000
\aAlert 0x0007
\bBackspace 0x0008
\fForm feed 0x000C
\n New line0x000A
\r Carriage return 0x000D
\t Horizontal tab 0x0009
\v Vertical tab 0x000B

The \u (or \x) escape sequence lets you specify any Unicode character via its four-digit hexadecimal code:

Demo Code

using System;//from  w w  w  .ja v  a  2  s  . co m
class Test
{
   static void Main(){
      char newLine = '\n';
      char backSlash = '\\';
      Console.WriteLine (backSlash);
      char copyrightSymbol = '\u00A9';
      char omegaSymbol     = '\u03A9';
      newLine         = '\u000A';
   }
}

Related Tutorials