c# - Exception when calling methods from console -
i making console app thats gonna invoke methods strings, part ok when comes parameters need help
this code, static void main(string[]args)
//gets variable void/method string void_name = console.readline(); //making type in case 'program' type type_ = typeof(program); //making route string 'void_name' methodinfo method_ = type_.getmethod(void_name); //getting optional parameters object[] obj = new object[] { "" }; foreach (parameterinfo _parameterinfo in method_.getparameters()) { obj[0] = console.readline(); } foreach (string obj_string in obj) { console.writeline(obj_string); } //calling functions method_.invoke(type_, obj); <-- exception } catch (exception exception_loop) { console.writeline(exception_loop.message); console.clear(); } } } public void helloworld(string something_) { console.writeline("\theisann: " + something_); }
how method declaration this:
public static void helloworld(string something_)
you calling static method.
Comments
Post a Comment