Nullable generic not consistant with primitive and object type #6139
-
C# version: 10 Given this code;
It works fine with this code:
But it doesn't compile when using a primitive type:
I was not expecting compilation issue depending of the type of the generic |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Nullability works differently between reference types and value types (including primitives) and they are not compatible with one another. |
Beta Was this translation helpful? Give feedback.
Nullability works differently between reference types and value types (including primitives) and they are not compatible with one another.
string?
is really juststring
, butint?
is actuallyNullable<int>
.