Answers for "repeat string in c#"

C#
5

c# repeat string x times

string result = new String('-', 5);
Output: -----
Posted by: Guest on May-21-2020
0

Repeat a string in C#

string indent = "---";
Console.WriteLine(indent.Repeat(0)); //would print nothing.
Console.WriteLine(indent.Repeat(1)); //would print "---".
Console.WriteLine(indent.Repeat(2)); //would print "------".
Console.WriteLine(indent.Repeat(3)); //would print "---------".
Posted by: Guest on January-23-2022

C# Answers by Framework

Browse Popular Code Answers by Language