此代碼是一個後續問題以下,如果你想看到:Parse to Nullable Enum爲空的類型入門類型定義打破了非可空類型
Type t = currentProperty.PropertyType;
if (t.GetGenericTypeDefinition() == typeof(Nullable<>))
t = t.GetGenericArguments().First();
我上線#2得到一個錯誤這是IF聲明。
System.Reflection.TargetInvocationException : Exception has been thrown by the
target of an invocation. ----> System.InvalidOperationException : This operation
is only valid on generic types.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
如何在執行IF語句中的代碼之前測試該條件?
什麼是內異常? – 2012-03-19 03:55:45