Here\'s a bit of code which prints out the squares of the numbers from 0 to 9:
for (int i = 0; i < 10; i++) Console.WriteLine(i*i);
Doin
Make your method like this in a static class "Extensions" for example:
public static void UpTo(this int n, Action proc) { for (var i = 0; i < n; i++) proc(i); }
And the usage:
var n = 10; n.UpTo(i => Console.WriteLine(i * i));
Hope this helps! :)