Skip to content

Instantly share code, notes, and snippets.

@pragmaticlogic
Last active December 30, 2015 12:49
Show Gist options
  • Save pragmaticlogic/7831784 to your computer and use it in GitHub Desktop.
Save pragmaticlogic/7831784 to your computer and use it in GitHub Desktop.
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