lundi 2 novembre 2015

How to access a method group expression using reflection?

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 access the exact same method group expression via reflection, having "Math.Sqrt" (or anything else valid) string value in a string variable.

(The task is not specific for static vs instance, just using it for the sake of sample. We can safely suppose the method has no overloads.)

Is this possible?





Aucun commentaire:

Enregistrer un commentaire