Created
March 7, 2012 00:34
-
-
Save plioi/1990116 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
var delayedGreetings = new List<Func<string>>(); | |
{ | |
using (var e = ((IEnumerable<string>)new[] { "Larry", "Moe", "Curly" }).GetEnumerator()) | |
{ | |
string name; | |
while (e.MoveNext()) | |
{ | |
name = e.Current; | |
delayedGreetings.Add(() => "Hello, " + name + "!"); | |
} | |
} | |
} | |
//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