Created
March 7, 2012 00:27
-
-
Save plioi/1990084 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (var name in new[] { "Larry", "Moe", "Curly" }) | |
{ | |
string name1 = name; //Added a seemingly-pointless local variable! | |
delayedGreetings.Add(() => "Hello, " + name1 + "!"); | |
} | |
//Some time later... | |
foreach (var greeting in delayedGreetings) | |
Console.WriteLine(greeting()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment