Hi!
Basically, Nullable<T>
is a structure, which explains things like calling .HasValue
will never throw a NullReferenceException
. I was wondering why - given a nullable which does not have a value - comparisons to null
are always true
, even when using Object.ReferenceEquals
, which I thought would return false because it is a structure.
Is there special behaviour built into the CLR to make this possible? It would probably also explain why the generic struct constraint does not allow nullables.
Best Regards,
Oliver Hanappi