try { Type type = typeof(Functions); MethodInfo method = type.GetMethod(msg); Functions c = new Functions(); ParameterInfo[] pars = method.GetParameters(); foreach (ParameterInfo p in pars) { send(p.ParameterType); } string result = (string)method.Invoke(c, null); send(result); } catch (Exception ex) { send(ex.Message); } So msg is string, I want to call function with parameters, for example like this:
string msg = "print(\"yes\")"; public class Functions { public string print(string text) { send(text); } } Currently if msg is equal to "print" it can execute simple print() function in Functions class:
public class Functions { public string print() { return "print() called"; } } But I don't know how to make it execute func with parameters, also get parameters from msg.
