using System;
namespace AnonymousMethod
{
delegate int Func();
class Program
{
static Func[] funcArr = new Func[10];
static void setPanelVariable(int i, Func f)
{
funcArr[i] = f;
}
static void Main(string[] args)
{
int i1 = 10;
int i2 = 20;
int i3 = 30;
setPanelVariable(0, () => i1);
setPanelVariable(1, () => i2);
setPanelVariable(2, () => i3);
for (int i = 0; i < 3; i++)
{
Console.WriteLine(funcArr[i]());
}
i1 = 111;
i2 = 121;
i3 = 131;
for (int i = 0; i < 3; i++)
{
Console.WriteLine(funcArr[i]());
}
Console.ReadLine();
}
}
}
this seems to work fine. shouldn't this be useable nicely for panel variables? looks very similar to what i did in python but maybe i am misunderstanding something. i am no c# expert.