曾南华

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

 

posted @ 2014-02-24 15:16  啄木鸟¥  阅读(160)  评论(0编辑  收藏  举报

曾南华