如何获取.NET中制表符的字符数?

发布于 2024-10-09 06:01:19 字数 125 浏览 0 评论 0原文

有没有办法获取 .NET 中制表符的长度(字符/空格数)?我正在将数据写入文本文件,并希望创建一个包含两列的表。由于第一列中的某些列条目看起来比其他列更长/更短,因此第二列看起来很丑。我尝试在条目之间插入几个 \t,但这并没有完全帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

离去的眼神 2024-10-16 06:01:19

您可以使用空格而不是制表符在 ASCII 表中整齐地格式化数据。

string.PadLeftstring.PadRight 方法可能会帮助您。

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.

流年里的时光 2024-10-16 06:01:19

制表符的宽度由显示它的程序决定,没有固定的数字。您可以在写入文件时轻松填充空格,字符串格式支持:

String.Format("{0,-16}", "String"); // align left
String.Format("{0,16}", "String");  // align right

示例: http://ideone.com/B4VvC< /a>

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

带上头具痛哭 2024-10-16 06:01:19

TAB 的位置没有固定数量。大多数编辑器允许您指定该数字。

There is no fixed number of positions for a TAB. Most editors allow you to specify that number.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文