【发布时间】:2012-04-19 09:40:34
【问题描述】:
使用方法签名,例如:
public interface TestInterface
{
void SampleMethodOut(out int? nullableInt);
void SampleMethod(int? nullableInt);
}
我使用typeof(TestInterface).GetMethods()[1].GetParameters()[0].ParameterType 获取类型,然后检查IsGenericType 和Nullable.GetUnderlyingType。如何使用带有 out 参数的方法做到这一点?
【问题讨论】:
-
对于不是out参数的IsGenericType是true并且Nullable.GetUnderlyingType返回Int32,但是对于out参数它是false和null。
-
那么对于非输出参数,
ParameterType返回typeof(Nullable<int>)-- 它对于输出参数返回什么?
标签: c# reflection parameters nullable out