Language question

  • Thread starter Thread starter Sagaert Johan
  • Start date Start date
S

Sagaert Johan

Is it possible to do something like this ?
string methodtoexecute="GetCount";

myclass.methodtoexecute();


now i solve it using a switch construct like this :

switch(methodtoexecute)
{
case "GetCount":
i=myclass.GetCount();
break;
case "GetRunTime":
i=myclass.GetRunTime();
default:
break;
}

Johan
 
Sagaert Johan said:
Is it possible to do something like this ?
string methodtoexecute="GetCount";

myclass.methodtoexecute();

Not quite like that, but using reflection you can do basically the same
thing. Look at Type.GetMethod, and MethodBase.Invoke for more
information.
 
Back
Top