I would like to know if there is a way in c# to execute a method, if we have only it’s name in a string ?
string methodname="method"
this.RunMethod(methodname)
Something like that ?
Thanks 🙂
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can create a generic method to invoke methods by their name on any instance you want this way:
And the use it to call a method on your own instance as you ask: