Answers for "Repeat a string in C#"

C#
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