Last active
December 30, 2015 12:49
-
-
Save pragmaticlogic/7831784 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 | |
{ | |
class MyFunc | |
{ | |
public Func<int> func { get; set; } | |
public MyFunc(int i) | |
{ | |
func = () => i; | |
} | |
} | |
private static MyFunc[] GetFunc() | |
{ | |
int SIZE = 5; | |
MyFunc[] myfuncs = new MyFunc[SIZE]; | |
for (int i = 0; i < SIZE; i++) | |
{ | |
myfuncs[i] = new MyFunc(i); | |
} | |
return myfuncs; | |
} | |
public static void Main(string[] args) | |
{ | |
var myfuncs = Program.GetFunc(); | |
foreach (var myfunc in myfuncs) | |
{ | |
Console.Out.WriteLine(myfunc.func()); | |
} | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment