I know how to get MethodInfo for a particular method, and also know how to call that method via reflection. However I could not figure out the following:
I have the assignment statement below:
Func<double, double> myFunc = Math.Sqrt;
I would like to get the exact same content for the myFunc variable via reflection, having the MethodInfo for Math.Sqrt in hand. Unfortunately building wrapper lambdas or Expression around the MethodInfo is not satisfying. I would like something like this:
Func<double, double> myFunc = GetMethodGroupFor(methodInfoForMathSqrt);
In case if the isolated sample does not explains what I would like to really do here is a bit more explanation:
I have to fill a Dictionary<string, Func<double, double>>
with 100s of method "keys" and delegates. Like:
myDictionary.Add("mykey", Math.Sqrt);
However I would not like to do this by 100s of assignment statement, instead I would like get the 100s of appropriate MethodInfos via reflection then in a for cycle fill the dictionary.
Is this possible?