Alan2
Alan2

Reputation: 24572

How can I repeat a character to make up a string if I have a number for the times to repeat?

I have this code:

vm.Points = phrase.Points.ToString();

I would like to replace it with something that would put an X character as many times as there are phrase.Points where phrase.Points is an integer.

So if phrase.Points has a value of 5 then I would like the value of vm.Points to be "XXXXX"

Upvotes: 1

Views: 75

Answers (1)

mshwf
mshwf

Reputation: 7449

You are looking for this:

new String('X', phrase.Points);

Upvotes: 5

Related Questions