I have a method that contains a delegate variable that points to another class. I want to call a method in this class through this delegate, but pass the name of the method as a string to the method containing the delegate.
How can I do that? Using reflection? Func<T>?
Edit:
Now I understand that reflection may not be the best solution.
This is what I have:
private static void MethodContainingDelegate(string methodNameInOtherClassAsString)
{
_listOfSub.ForEach(delegate(Callback callback)
{
callback.MethodNameInOtherClass();
callback.MethodNameInOtherClassAsString();
}
});
}
So basically, I'm looking for a way to make the callback delegate βrecognizeβ that my NameInOtherClassAsString method is actually a method to execute in another class.
Thank!
source
share