I would like to be able to store various static methods in a List and later look them up and dynamically call them.
Each of the static methods has different numbers of args, types and return values
static int X(int,int)....
static string Y(int,int,string)
I’d like to have a List that I can add them all to:
List<dynamic> list
list.Add(X);
list.Add(Y);
and later:
dynamic result = list[0](1,2);
dynamic result2 = list[1](5,10,"hello")
How to do this in C# 4?
You can create a list of delegate-instances, using an appropriate delegate-type for each method.