CSharp examples for Language Basics:string
An escape sequence is a backslash followed by a character with a special meaning.
Escape sequence characters
Char | Meaning | Value |
---|---|---|
\' | Single quote | 0x0027 |
\" | Double quote | 0x0022 |
\\ | Backslash | 0x005C |
\0 | Null | 0x0000 |
\a | Alert | 0x0007 |
\b | Backspace | 0x0008 |
\f | Form feed | 0x000C |
\n | New line | 0x000A |
\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:
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'; } }