Use this constructor on System.String
:
new String(' ', 10);
http://msdn.microsoft.com/en-us/library/xsa4321w(v=vs.110).aspx
Here’s a neat extension method you can use, as well (although it’s probably better just to use the String
constructor and save the extra method call):
public static class CharExtensions
{
public static string Repeat(this char c, int count)
{
return new String(c, count);
}
}
...
string spaces=" ".Repeat(10);