【发布时间】:2018-09-26 08:15:23
【问题描述】:
我目前正在创建一个 ASCII 表构建器,这是 GXP 环境中某些自动化数据库报告所必需的。
鉴于我有宽度为 n 的表格行,例如:
| this | is | an | example | row |
|<-- width = 32 -->|
我现在想添加标题和分隔符,例如:
#================================#
| this | is | an | example | row |
|--------------------------------|
| 1 | 2 | 3 | 4 | 5 |
| 3 | 9 | 77 | 327814 | 2 |
|--------------------------------|
当然,我可以通过以下方式做到这一点:
List<string> asciiTable = new List<string();
string topBorder = "#";
string otherBorder = "|";
for (int i = 1; i == n; i++)
{
topBorder += "=";
otherBorder += "-";
}
topBorder += "#";
otherBorder += "|";
asciiTable.Add(topBorder);
但我希望有这样的东西:
List<string> asciiTable = new List<string>();
asciiTable.Add("#" + /* add("=",n) */ + "#");
【问题讨论】:
-
new string('z',234324)