Execute a string as a method?

 
string methodString= "MyMethod()";
//execute methodString; ??????
How to execute a string as a method?


 
rod178:
How to execute a string as a method?


  if(methodString== "MyMethod()")
     MyMethod();             
 
GumRai:


Not the solution I was looking for

I desire to enter the methods dependent on variable values created. This would include overloading.

 
rod178:


Not the solution I was looking for

I desire to enter the methods dependent on variable values created. This would include overloading.

You then have to use OOP and pointers.
 
angevoyageur:
You then have to use OOP and pointers.


Yes, that is an option, although I was hoping that a more direct approach was available, as is in some other languages.

eg

eval 'MyMethod()'    # Ruby code to execute a method from  a string
 
rod178:


Yes, that is an option, although I was hoping that a more direct approach was available, as is in some other languages.

eg

Unfortunately not.
Reason: