Pass Method as Parameter using C#

后端 未结 12 1521
不知归路
不知归路 2020-11-21 23:30

I have several methods all with the same parameter types and return values but different names and blocks. I want to pass the name of the method to run to another method tha

12条回答
  •  轮回少年
    2020-11-22 00:21

    If you want the ability to change which method is called at run time I would recommend using a delegate: http://www.codeproject.com/KB/cs/delegates_step1.aspx

    It will allow you to create an object to store the method to call and you can pass that to your other methods when it's needed.

提交回复
热议问题