Here is what i want to do, and i know it is possible with perl, php, python and java, but i am working with c#
how can i do the following:
public void amethod(string functionName)
{
AVeryLargeWebServiceWithLotsOfMethodsToCall.getFunctionName();
}
I want to pass the functionName to the method and I want it to be executed as above.
How this can be done?
Do i need ANTLR or any other tool for this?
Thanks.
You can execute a method by name via Reflection. You need to know the type, as well as the method name (which can be the current object’s type, or a method on a different object, or a static type). It looks like you want something like:
Edit in response to comment:
It sounds like you actually want to get a result back from this method. If that’s the case, given that it’s still a static method on the service (which is my guess, given what you wrote), you can do this. MethodInfo.Invoke will return the method’s return value as an Object directly, so, if, for example, you were returning a string, you could do: