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
2008-11-17 05:27:13
For Mac (pre OS-X) it was \r :)
JaredPar
2008-11-17 05:28:49
Since neither of the people using pre-OSX Macs could find the power switch it didn't matter.
Peter Wone
2008-11-17 06:07:05
I couldn't say better, CMS.
PhiLho
2008-11-17 06:11:04
+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
2008-11-17 05:27:27
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
2008-11-17 05:33:26
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
2008-11-17 05:41:06