MethodInfo類的一般使用!


    1、MethodInfo類是在System.Reflection命名空間底下,既然是在Reflection空間底下。故名思議關於反射相關的操作,其中比較重要的方法是Invoke()方法,它

是加載相同程序集的方法。簡單用法

        string command = "AnnouncementSave";
        //通過反射獲取調用的具體方法
        System.Reflection.MethodInfo method = this.GetType().GetMethod(command);
        if (method != null)
       {
                //Execute Method
                method.Invoke(this, new object[] { context });
       }

       調用方法:

       public void AnnouncementSave(HttpContext context)
      {

      }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM