Hi,
I have a string which i will be getting from the input from a user.
But i should take the input what user gives and obviously that is the name of a function in my code. So i should call the function which the user has entered. How can i do this?
Example: Suppose the user has entered a name "interpolation" in the textbox in the form and then he presses enter. Then i should read the name as follws:
String ^ function_call = textbox->Text;
and after this operation i should call the function interpolation which user has entered.
int index = interpolation();//this is what i need this function will return a integer.
Loading
VulpesPosted Jun 6, 2012, 8:27 AM
Karthik AgarwalPosted Jun 6, 2012, 7:28 AM
I don't wanna do it in if else ladder and i want to do it probably in some other way.
VulpesPosted Jun 6, 2012, 7:20 AM
if (function_call == "interpolation")
{
int index = interpolation();
// do something with index
}
else if () // etc
Otherwise, you'd need to use reflection to make 'late bound' calls.
Is the function you're calling an instance or static method of some class or struct or is it a global function of the current assembly?