如何知道参数的个数和类型?
如何知道返回类型?
如何检查返回类型是否为void?
Use MethodInfo.ReturnType http://msdn.microsoft.com/en-us/library/system.reflection.methodinfo.returntype.aspx确定返回类型,以及MethodBase.GetParameters() http://msdn.microsoft.com/en-us/library/system.reflection.methodbase.getparameters.aspx来了解参数。 (MethodInfo
源自于MethodBase
,所以一旦你有了MethodInfo
via Type.GetMethod
等等,你可以同时使用ReturnType
and GetParameters()
.)
如果该方法是void
,返回类型将是typeof(void)
:
if (method.ReturnType == typeof(void))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)