[ACCEPTED]-C# String creation (specified length)-string

Accepted answer
Score: 33

You can use the string constructor that takes a char and an int. It creates a string instance with 1 the char repeated the specified number of times.

Score: 12

As bdukes mentions there's constructor, that 6 takes a char and an int. That will construct 5 a string of the given length filled with 4 the char.

However, keep in mind, that strings 3 are immutable in .NET, so if you want to 2 create a specific string buffer, you should 1 use StringBuilder instead.

More Related questions