Repeat
Creates a new string by repeating the given string n times.
- Use
Enumerable.Repeat()to repeatsntimes,string.Concat()to convert the result to astring.
using System.Linq;
public static partial class _30s
{
public static string Repeat(string s, int n)
{
return string.Concat(Enumerable.Repeat(s, n));
}
}_30s.Repeat("Ha",5); // "HaHaHaHaHa"