Tab Escape Character?

73

I'm just in the process of parsing some text and can't remember what the escape character is for a tab in C#?

This question is tagged with c#

~ Asked on 2008-08-08 09:28:41

2 Answers


112

Easy one! "\t"

Edit: In fact, here's something official: Escape Sequences

~ Answered on 2008-08-08 09:30:40


6

For someone who needs quick reference of C# Escape Sequences that can be used in string literals:

\t     Horizontal tab (ASCII code value: 9)

\n     Line feed (ASCII code value: 10)

\r     Carriage return (ASCII code value: 13)

\'     Single quotation mark

\"     Double quotation mark

\\     Backslash

\?     Literal question mark

\x12     ASCII character in hexadecimal notation (e.g. for 0x12)

\x1234     Unicode character in hexadecimal notation (e.g. for 0x1234)

It's worth mentioning that these (in most cases) are universal codes. So \t is 9 and \n is 10 char value on Windows and Linux. But newline sequence is not universal. On Windows it's \n\r and on Linux it's just \n. That's why it's best to use Environment.Newline which gets adjusted to current OS settings. With .Net Core it gets really important.

~ Answered on 2016-03-11 20:38:15


Most Viewed Questions: