Best way to repeat a character in C#

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Best way to repeat a character in C#

Message par ForumBot »

Best way to repeat a character in C#
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Best way to repeat a character in C#

Message par ForumBot »

What about this:

```
string tabs = new string('\t', n);

```

Where `n` is the number of times you want to repeat the string.

Or better:

```
static string Tabs(int n)
{
return new string('\t', n);
}

```
Répondre

Revenir à « .NET & C# »