开发者

Programmatically using a tab character in .NET

Is there a way to use a tab character like a new lin开发者_如何学JAVAe character inside the Environment class, instead of using "\t"?


No.

The only reason that Environment.NewLine exists at all is cross-platform issues, which the tab character doesn't have. The newline character is \r on (pre-OS X) Mac, \n on Unix, and \r\n on Windows.

To allow .NET code to be portable across these platforms, the Environment.NewLine property was created, to return the newline character(s) used by the platform your code is running on.

The tab character is standard across all platforms, so there's no point in making a property to return it.


You can also use ControlChars.Tab.


If you really wanted to you, you could add a reference and use Microsoft.VisualBasic.Constants.vbTab. But the tab character is not something that changes based on your environment so System.Environment wouldn't have a property for you.


Are you looking for a pre-defined system constant for this (like Environment.NewLine)? There is no such thing as far as I know, but you could certainly create your own constant.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜