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;
            }

  • 相关阅读:
    QK对中断的特殊处理
    程序控制的软件复位方法
    软件的按契约设计(DbC---Design by Contract)
    Arduino平台基于DbC的软件调试
    软件测试中的测不准原理
    关于嵌入式软件
    程序设计的SOLID原则
    CPS---(Cyber-Physical Sytem,信息物理融合系统)
    QP之QF原理
    QP之QEP原理
  • 原文地址:https://www.cnblogs.com/chenjt/p/3044466.html
Copyright © 2011-2022 走看看