How to repeat a set of characters

前端 未结 3 452
醉话见心
醉话见心 2021-01-17 10:11

I\'d like to repeat a set of characters multiple times. I know how to do it with a single character:

string line = new string(\'x\', 10);

相关标签:
3条回答
  • string line = new String('x', 10).Replace("x", "-.");
    
    0 讨论(0)
  • 2021-01-17 10:52
    var result = String.Join("", Enumerable.Repeat("-.", 10));
    
    0 讨论(0)
  • 2021-01-17 10:54

    A slight variation on the answer by Bala R

    var s = String.Concat(Enumerable.Repeat("-.", 10));
    
    0 讨论(0)
提交回复
热议问题