namespace MY
{
    public partial class Ajax : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string go=Request["go"];//动态参数
            //想在这里使用反射动态调用下面的函数(下面的函数跟这行代码同处一个.cs文件中)
            //此处,请高手写代码,谢谢!原理就不用讲了,网上一搜很多。我就是研究了好久,没搞定,才上来直接求代码的!        
        }
        public void M1()
        {
                Response.Write("这是函数1");
        }
        public void M2()
        {
                Response.Write("这是函数2");
        }
    }
}

解决方案 »

  1.   

    楼主:你要先了解反射是什么原理了。你要知道反射的DLL是什么吧。要知道反射的类是什么吧。这些都不知道,怎么反射?
      

  2.   

    反射是载入同函数名的不同DLL.
      

  3.   

    Type t = this.GetType();
    MethodInfo m = t.GetMethod(go);
    m.Invoke(this, null);
      

  4.   

       string _MethodName = "M1";            MethodInfo _Method = this.GetType().GetMethod(_MethodName);            _Method.Invoke(this, null);OR 
       string _MethodName = "M2";