“ClosureAndForeach” (Problem)
What will the following code display?
var actions = new List<Action>();
foreach (var i in Enumerable.Range(1, 3))
actions.Add(() => Console.WriteLine(i));
foreach (var action in actions)
action();
Last modified 4yr ago