日期:2014-05-18  浏览次数:20793 次

Type.GetMethods
反射获取指定参数的方法
如何取得:得指定参数的方法
比如:getMethods可以取得   void   Test1(int   i)   和void   test2(int   i,   int   j);

我如何得到   test2,也就是,我只要参数是两个int   的方法?


------解决方案--------------------
返回的是MethodInfo数组。数组中方法的排列顺序是按字母顺序。试试GetMethod( "test2 ")。
------解决方案--------------------
typeof(...).GetMethod( "test2 ");
------解决方案--------------------
使用这个重载方法:
MethodInfo GetMethod (
string name,
Type[] types
)
第2个参数就是你要调用方法的参数类型数组