Created
January 21, 2011 20:06
-
-
Save beccasaurus/790304 to your computer and use it in GitHub Desktop.
5.Times(i => ...};
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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