Create a string of Repeating Characters
C#, C# Language October 12th, 2006Creating a string of repeating characters is really simple in c#, however it is not in the obvious place you would look. First I tried the String class, hoping there would be a static like String.RepeatString, and even looked in the StringBuilder class. Eventually found it in a very logical place when you think about it, the String classes constructor.
So to create a repeating string simply use
String myString = new String('x', 12);
which will create a string of x’s 12 characters long.
November 4th, 2008 at 3:05 am
Hello people! Nice site!n