Reputation: 3017
Is there a way to get the length (number of characters/blanks) of a tab in .NET? I am writing data to a text file and would like to create a table with two columns. Since some column entries in the first column appear to be longer/shorter than others, the second column looks ugly. I tried inserting a couple of \t's between entries, but that didn't fully help.
Upvotes: 1
Views: 130
Reputation: 838376
You can use spaces instead of tabs to format your data neatly in an ASCII table.
The string.PadLeft
and string.PadRight
methods may help you.
Upvotes: 2
Reputation: 138037
Tab width is determined by the program the shows it, there isn't a fixed number. You can easily pad with spaces when writing the file, a string's format supports that:
String.Format("{0,-16}", "String"); // align left
String.Format("{0,16}", "String"); // align right
Example: http://ideone.com/B4VvC
Upvotes: 2
Reputation: 39309
There is no fixed number of positions for a TAB. Most editors allow you to specify that number.
Upvotes: 0