Answers for "c# repeat string x times"

C#
5

c# repeat string x times

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

C# repeat x times

// Normally in a namespace, of course.
public class LoopUtilities
{
    public static void Repeat(int count, Action action)
    {
        for (int i = 0; i < count; i++)
        {
            action();
        }
    }
}

using static LoopUtilities;

// Class declaration etc, then:
Repeat(5, () => Console.WriteLine("Hello."));
Posted by: Guest on October-01-2020

C# Answers by Framework

Browse Popular Code Answers by Language