how to know the number and type of parameters?
how to know the return type?
how to check whether the return type is void?
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()
.)
If the method is void
, the return type will be typeof(void)
:
if (method.ReturnType == typeof(void))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.