I have created a class library, which has 4 classes each class have 1 method.
First class is the main class for me, in my first class, i have a string called calltoaction, in this string i will be getting the one of below list dynamically
- class2.Method2()
- class3.Method3()
- class4.Method4()
now i want to execute the “class2.method2” from the string “calltoaction”.
Say for ex:
class Class1
{
public void method1()
{
string calltoaction = "Class2.Method2()";
}
}
How to execute the “Class2.Method” from the string?
Use an
Actioninstead of a string (Assuming you don’t need a return value. If you do – useFunc):This is for an idea of how to use it: