I can\'t understand how to loop through an Action list. When I try it, I end up with the values being the same as the previous iteration.
Action
Here\'s the co
This is a pretty complicated situation. The short answer is to create a copy of the local variable before assigning it to the closure:
string copy = str; actions.Add(new Action(() => { Trace.WriteLine(copy); }));
Check out this article on closures for more information.