我想实现这个
string a = "Hello";
Console.Write (a * 10);
我希望它打印出来:
Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello
我知道在python中我可以做到
a = "hello"
print a * 10
但是如何在C#中执行此操作?
答案 0 :(得分:4)
string repeated = string.Join(" ", Enumerable.Repeat("Hello", 10));