In C#, using .NET Framework 4, is there an elegant way to repeat the same action a determined number of times? For example, instead of:
int repeat = 10; for
Without rolling out your own extension, I guess you can do something like this
Action toRepeat = () => { Console.WriteLine("Hello World."); this.DoSomeStuff(); }; int repeat = 10; Enumerable.Range(0, repeat).ToList().ForEach(i => toRepeat());