1

I am currently Creating a ASCII table builder which is required for some automated database reports in a GXP environment.

Given that I have table rows with a width of n such as:

| this | is | an | example | row |
|<--       width = 32         -->|

I now want to add headers and spacers such as:

#================================#
| this | is | an | example | row |
|--------------------------------|
| 1    | 2  | 3  | 4       | 5   |
| 3    | 9  | 77 | 327814  | 2   |
|--------------------------------|

of course I could do this in the following way:

List<string> asciiTable = new List<string();
string topBorder = "#";
string otherBorder = "|";
for (int i = 1; i == n; i++)
{
    topBorder += "=";
    otherBorder += "-";
}
topBorder += "#";
otherBorder += "|";
asciiTable.Add(topBorder);

but I hope there is something such as:

List<string> asciiTable = new List<string>();
asciiTable.Add("#" + /* add("=",n) */ + "#"); 
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
julian bechtold
  • 1,875
  • 2
  • 19
  • 49

1 Answers1

4

You could use new String('=', n); which will create a string with the character '=' repeated n times.

Hayden Hall
  • 346
  • 3
  • 6