Character line break

  • Thread starter Thread starter John Sutor
  • Start date Start date
Hi,
Try to use PadRight, a function on the string object.

string s = "".PadRight(20, '-');

/Mats-Lennart
 
If i understand you right, you want to repeat a character automatically.
Then, try the cool overloaded String constructor of signature:
...ctor ( char c, int count )

// Writes
"--------------------------------------------------------------------------------"
sw.WriteLine(new string('-', 80));
 
something like this?

string myLine = DrawLine ( 80 );

string DrawLine( int length )
{
StringBuilder sb = new StringBuilder();
for ( int x = 0; x < length; x++)
{
sb.Append("-");
}

return sb.ToString();
}
 
Back
Top