1

Possible Duplicate:
Best way to repeat a character in C#

I'm making a big Comma separated CSV file. Most of the files fields are null and it would be provided later on, so I need to insert just a comma. I made a simple method:

 private string MakeComma(int CommaNumber)
{
    StringBuilder sb = new StringBuilder(string.Empty);
    for (int i = 0; i < CommaNumber; i++)
    {
        sb.Append(",");
    }
    return sb.ToString();
}

I'm wondering if there is a better way using Linq, Join etc.

Community
  • 1
  • 1
Frenchi In LA
  • 3,139
  • 3
  • 25
  • 41

1 Answers1

10
new string(',', 42);

See the documentation

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964