Action action 获取方法名称问题

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  获取到的方法名称是 <csDemo>b_x_1  这个格式 我想直接获取到 csDemo
除了字符串截取有其他的方法吗?


明月笑刀无情
浏览 751回答 2
2回答

大话西游666

为什么不用截取字符串

慕姐8265434

用反射获取方法名称,你可以获取你想要的一切
打开App,查看更多内容
随时随地看视频慕课网APP