csharp repeat string x times

Code Example - csharp repeat string x times

                
                        string result = new String('-', 5);
Output: -----
                    
                
 

csharp 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."));
                            
                        
 

repeat 10 timesw csharp

                        
                                for (int i = 0; i < 10; i++)
        {

        }