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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM