views:

284

answers:

2

Is there an equivalant to Environment.NewLine in DotNet for a Tab character?

+10  A: 

NewLine is on the Environment class because the new line specification varies between platforms:

It's "\r\n" for non-Unix platforms and "\n" for Unix platforms. However tab is always "\t".

CMS
For Mac (pre OS-X) it was \r :)
JaredPar
Since neither of the people using pre-OSX Macs could find the power switch it didn't matter.
Peter Wone
I couldn't say better, CMS.
PhiLho
+2  A: 

Short answer is: no, tab does not change between platforms as newline might, so there is no need for one.

Long answer is: technically, yes, you could use the one provided by VB in the Microsoft.VisualBasic.dll. I think it's Microsoft.VisualBasic.Constants.vbTab, but there's no good reason to use it in C# as I said above.

Xiaofu
It's useful in VB simply because VB doesn't parse the "\t" pattern (or any other backslash-escaped pattern) in string constants. In VB, you have to concatenate the vbTab constant—or Chr(9)—to your string.
P Daddy
Yes, you're quite right there, I was answering from the point of view of C# as he asked, but I could have qualified it as "no good reason to use it in C#".
Xiaofu
VB doesn't have shortcomings. It's wonderful.
Peter Wone