简体   繁体   中英

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"

您正在寻找这个:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM