How to multiply an "X" character as many times as you want?

7

Is there a method that multiplies an "X" character as many times as I want? example:

I have the "P" character

  

P x 5="PPPPP"

Is there a ready method in .Net?

    
asked by anonymous 26.02.2016 / 15:42

2 answers

10

Yes, there is, just build the string indicating the number of times you want:

var texto = new String('P', 5);

See running on dotNetFiddle .

Documentation .

    
26.02.2016 / 15:43
6

In VB.NET

It's the same thing as the @bigown response, but in VB.NET, since no language was specified.

Dim texto = New String("P", 5)

See the dotNetFiddle

    
26.02.2016 / 15:58