Skip to content

Instantly share code, notes, and snippets.

@beccasaurus
Created January 21, 2011 20:06
Show Gist options
  • Save beccasaurus/790304 to your computer and use it in GitHub Desktop.
Save beccasaurus/790304 to your computer and use it in GitHub Desktop.
5.Times(i => ...};
using System;
public static class Int32TimesExtension {
public static void Times(this int numberOfTimes, Action<int> action) {
for (int i = 0; i < numberOfTimes; i++)
action.Invoke(i);
}
}
public class Program {
public static void Main(string[] args) {
5.Times(i => Console.WriteLine("hello {0}", i));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment