Created
December 6, 2013 22:24
-
-
Save pragmaticlogic/7833186 to your computer and use it in GitHub Desktop.
This file contains 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
class Program | |
{ | |
private static Func<int>[] GetFunc() | |
{ | |
int SIZE = 5; | |
Func<int>[] func = new Func<int>[SIZE]; | |
for (int i = 0; i < SIZE; i++) | |
{ | |
int j = i; | |
func[i] = () => j; | |
} | |
return func; | |
} | |
public static void Main(string[] args) | |
{ | |
var funcs = Program.GetFunc(); | |
foreach (Func<int> func in funcs) | |
{ | |
Console.Out.WriteLine(func()); | |
} | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment