Is there a built-in function to repeat a string or char in .NET?
string.Concat(Enumerable.Repeat("ab", 2));
returns
"abab"
string.Join("", Enumerable.Repeat("ab", 2));
Returns
"abab"
And
string.Join("", Enumerable.Repeat('a', 2))
Returns
"aa"
For strings you should indeed use Kirk's solution:
string.Join("", Enumerable.Repeat("ab", 2));
However for chars you might as well use the built-in (more efficient) string constructor:
new string('a', 2); // returns aa
new String('*', 5)
See Rosetta Code.