10
Suppose I'm given an object and a string that holds a method name, how can I return a delegate to that method (of that method?) ?
Example:
MyDelegate GetByName(ISomeObject obj, string methodName)
{
...
return new MyDelegate(...);
}
ISomeObject someObject = ...;
MyDelegate myDelegate = GetByName(someObject, "ToString");
//myDelegate would be someObject.ToString
Thanks in advance.
One more thing -- I really don't want to use a switch statement even though it would work but be a ton of code.