c# how to repeat a string code example Example: c# repeat string x times string result = new String('-', 5); Output: -----