Recently while revising one of the concept I came across a situation which is interesting and I want to know why this happens.
We know one concept that we can't assign null values to Value types i.e. Struct
, int
, DateTime
, etc.
In order to assign null
we need nullable type i.e.
int i
should be replaced with Nullable<int> i = null
But if we see Nullable<T>
it is also of type struct
then how come null
can be assigned without stating any error? Why Microsoft contradicted it's own statement of "Null can't be assigned to value type"
If someone knows the reason behind this?