/* * Created by SharpDevelop. * User: matty * Date: 6/02/2008 * Time: 2:29 PM * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using System.Collections.Generic; namespace ClosureFun { class Program { public delegate void Func(); public static void Main(string[] args) { Console.WriteLine("Hello World!"); // TODO: Implement Functionality Here List list = new List(); FunLoop(0,list); foreach(Func f in list) { f(); } } public static void FunLoop(int i,List list) { if(i > 100) return; Func foo = delegate() { Console.WriteLine(i.ToString()); }; list.Add(foo); FunLoop(i+1,list); } } }