如何知道的参数的数量和类型?
how to know the number and type of parameters?
怎么知道的返回类型?
如何检查返回值是否无效?
how to check whether the return type is void?
使用MethodInfo.ReturnType确定返回类型,和MethodBase.GetParameters()要了解的参数。 (的MethodInfo
从 MethodBase
派生,所以一旦你已经得到了的MethodInfo
通过 Type.GetMethod
等,可以同时使用的返回类型
和 GetParameters()
)
Use MethodInfo.ReturnType
to determine the return type, and MethodBase.GetParameters()
to find out about the parameters. (MethodInfo
derives from MethodBase
, so once you've got the MethodInfo
via Type.GetMethod
etc, you can use both ReturnType
and GetParameters()
.)
如果该方法无效
,返回类型为 typeof运算(无效)
:
If the method is void
, the return type will be typeof(void)
:
if (method.ReturnType == typeof(void))
上一篇:DataContractSerializer的问题事件/委托场事件、问题、DataContractSerializer
下一篇:什么是Java的等效AggregateException从.NET?Java、AggregateException、NET