Recently i found out i can write in a \"
by writing two \" ex @\"abc\"\"def\"
. I find the @ string literal useful. But how do i write in a tab or n
That quote escape sequence (""
) is the only "escape" that works in verbatim string literals. All other escapes only work in regular string literals.
As a workaround you may use something ugly like this:
string.Format(@"Foo{0}Bar", "\t");
or include an actual tab character in the string. That should also work with regular string literals, but whitespace, especially tabs, usually doesn't survive different text editors well :-)
For newlines it's arguably much easier:
@"Foo
Bar";