How can I store delegates (named, anonymous, lambda) in a generic list? Basically I am trying to build a delegate dictionary from where I can access a stored delegate using
Well, here's a simple example:
class Program
{
public delegate double MethodDelegate( double a );
static void Main()
{
var delList = new List {Foo, FooBar};
Console.WriteLine(delList[0](12.34));
Console.WriteLine(delList[1](16.34));
Console.ReadLine();
}
private static double Foo(double a)
{
return Math.Round(a);
}
private static double FooBar(double a)
{
return Math.Round(a);
}
}