Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically using a tab character in .NET

Tags:

c#

.net

Is there a way to use a tab character like a new line character inside the Environment class, instead of using "\t"?

like image 695
Joan Venge Avatar asked Apr 21 '10 21:04

Joan Venge


People also ask

What is the code for a tab character?

The ASCII code for tab is 09.

How do you represent a tab in C#?

In C#, we use the \t escape character to add a tab character space in string in C#. If you use the "\t" escape character once, it adds one tab space in string. This tab character can be used in a string or just directly passed and concatenated with a string and written to console.

What tab character means?

A tab character defines the space between two document elements. For example, you can separate numbers from list items, or columns of text, by using tabs. You can then set tab stops that define the location and alignment of the tabbed text. Click to view larger image. You can align text in different ways by using tabs.


1 Answers

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.

like image 118
SLaks Avatar answered Sep 25 '22 02:09

SLaks