How can I store delegates (named, anonymous, lambda) in a generic list? Basically I am trying to build a delegate dictionary from where I can access a stored delegate using
public delegate void DoSomething(); static void Main(string[] args) { List lstOfDelegate = new List(); int iCnt = 0; while (iCnt < 10) { lstOfDelegate.Add(delegate { Console.WriteLine(iCnt); }); iCnt++; } foreach (var item in lstOfDelegate) { item.Invoke(); } Console.ReadLine(); }