Skip to content

Instantly share code, notes, and snippets.

@plioi
Created March 7, 2012 00:27
Show Gist options
  • Save plioi/1990084 to your computer and use it in GitHub Desktop.
Save plioi/1990084 to your computer and use it in GitHub Desktop.
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