-4

I saw somewhere on this board where someone created a string to print that held multiple variables that you could print a form. I can find the original question but would like to use the way the string was constructed.

I want to have the string like hold something like this.

string("|", {size of field1}, "|", {size of field2}, "|", {size of field3}, "|"), field1, field2, field3);

I want the size for each field to be constant so it makes a nice table.

Matt Burland
  • 44,552
  • 18
  • 99
  • 171
coolercargo
  • 247
  • 2
  • 13

1 Answers1

1
string formattedString = String.Format("{0}|{1}|{2}", field1, field2, field3);

Alternatively if you're not sure how many strings to combine you will have you can use the Join method.

string formattedString = String.Join("|", stringsToJoin);

In this case stringsToJoin should be an array.

Teeknow
  • 1,015
  • 2
  • 17
  • 39