-
According to the following post, Activator.CreateInstance should return object instead of object?. But in .NET 5 it is marked as returning object?. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I don't understand, that question complains that |
Beta Was this translation helpful? Give feedback.
-
When I read the accepted answer in the post that I referenced, I thought it meant that the fix got rid of the null return. But it seems that is not the case. I guess the point is that you cannot return an object referring to a Nullable<T> due to the boxing behavior of Nullable. I would have thought it would throw InvalidOperationException in this situation... Thanks for the clarification. |
Beta Was this translation helpful? Give feedback.
I don't understand, that question complains that
Activator.CreateInstance
does returnnull
in some cases (namely, for nullable value types). So I thinkobject?
is the correct return type.