zoukankan      html  css  js  c++  java
  • 根据方法名反射到方法后去执行方法

     /// <summary>
            /// 根据方法名称反射调用相应的方法
            /// </summary>
            /// <param name="methodname"></param>
            public string InitCombox(string method)
            {
                Type type = this.GetType();
                MethodInfo m = type.GetMethod(method);
                if (m == null) throw new Exception("method is null");
                try
                {

                //如果需要传递参数 

          //object[] objs = { "参数1", "参数2", "参数3" };
                   //objs = new object[] { objs};
                    return m.Invoke(this, null).ToString();
                }
                catch (Exception)
                {
                    throw new Exception("method is null");
                }
            }
            public string InitComboxOrgBigType()
            {
                return ConstDefine.OrgBigType;
            }

            public string InitComboxOrgSmallType()
            {
                return ConstDefine.OrgSmallType;
            }

            public string InitComboxOrgLevel()
            {
                return ConstDefine.OrgLevel;
            }

  • 相关阅读:
    BitTorrent源代码分析
    获取网卡网络流量
    获取进程cpu占用
    Python中的下划线命名规则
    python的内建函数isinstance
    python类
    内建函数print(python3.0)
    小象增强学习课件DQN网络和Q-learning
    11月深度学习班第5课风格变化NeuralStyle
    11月深度学习班第5课图像物体检测:rcnn/fast-rcnn/faster-rcnn
  • 原文地址:https://www.cnblogs.com/chenjt/p/3044466.html
Copyright © 2011-2022 走看看