Sometimes I want to repeat a given string several times for formatting purposes. The following code can be either made into an extension method with slight changes or a utility method:
string.Join("", Enumerable.Repeat("a", 8).ToArray());
The code above repeat "a" 8 times and returns "aaaaaaaa".
No comments:
Post a Comment