如果只打算重复相同的字符,则可以使用接受char和重复次数的字符串构造函数
new String(char c, int count)。
例如,要重复五次破折号:
string result = new String('-', 5);Output: -----
如果只打算重复相同的字符,则可以使用接受char和重复次数的字符串构造函数
new String(char c, int count)。
例如,要重复五次破折号:
string result = new String('-', 5);Output: -----