Hi,
I am using reflection / late binding to invoke a method. This all works correctly as long as my paramater types match exactly the parameter types for the method.
However I need it to attempt to parse the supplied parameters and convert their types to match that of the method being invoked. I guess its possible through setting some flags on the Binder ?? however I cannot get this to work.
Here is my code so far (which will error if an incorrect paramater type is passed)
Java
object[] methodParams = { "x", "y" };
Type thisType = this.GetType();
MethodInfo methodToCall = thisType.GetMethod("MyMethod");
methodToCall.Invoke(this, methodParams);
Mike GoldRank #50 · 30.6K pointsPosted Jun 20, 2008, 10:36 AM EDT
Martyn Harris2 pointsPosted Jun 20, 2008, 11:09 AM EDT
The method is not known at design / compile time. Hence the reason for using reflection.
If I knew the method to be called then I would just hard code it.