C#根据字符串名称 得到对应的方法

  public string GetMethod(string methodName, BookingRequest bookingId)
        {
            EmailTemplate p1 = new EmailTemplate();//
            Type t = p1.GetType();
   var mi = t.GetMethod(methodName, new Type[] { typeof(BookingRequest) });  //得到对应的方法 
            //通过反射执行ReturnAutoID方法,返回AutoID值
            object body= mi.Invoke(p1, new object[] { bookingId });//方法和参数
            return body<span style="font-family: Arial, Helvetica, sans-serif;">.ToString();</span>
        }

 

posted on 2018-10-18 23:22  HOT SUMMER  阅读(1859)  评论(0)    收藏  举报

导航