C# 反射

 public class HelloWorld:IHttpHandler
    {
        public bool IsReusable
        {
            get { throw new NotImplementedException(); }
        }

        public void ProcessRequest(HttpContext context)
        {
            HelloWorld g = new HelloWorld();  //如果获取的方法是静态的就不需要创建实例
            MethodInfo info = g.GetType().GetMethod("Fuck",new Type[]{typeof(string)});//获取重载方法
         string hao = ""; hao = info.Invoke(g,new object[] {"广州你好"}).ToString(); context.Response.Write(hao); }
     //两个Fuck重载方法 public string Fuck(string s) { return s; } public string Fuck(string s, int we) { return "你不"+s+" "+we; } }
原文地址:https://www.cnblogs.com/xuehaiyiye/p/3564682.html