Is there a “Space(n)” method in C#/.Net?

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);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)