ITPub博客

首页 > > > Action action 获取方法名称问题

Action action 获取方法名称问题

作者:deeply 时间:2019-11-13 11:53:07 0 删除 编辑

code:

public void ExecuteVoidFunc(Action action,string methodName="")
        {
            if (action == null) return ;
            try
            {
                action.Invoke();
            }
            catch (Exception ex)
            {
                string temp = (methodName + "").Length == 0 ? action.Method.Name : methodName;
            }
        }

Action是个委托方法 希望获取他的调用他的方法名称

action.Method.Name 获取到的方法名称是 b_x_1 这个格式 我想直接获取到 csDemo

除了字符串截取有其他的方法吗?

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1978/viewspace-3168997/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-05-30

  • 博文量
    215
  • 访问量
    24534