Some time ago I thought that Nullable<> value types are classes, encapsulating value types and a bool to HasValue. With some implicit cast operador for null, just implemented at BCL.
But being a struct, how this can be achieved? Nullable<> struct is "special" for CLR?
Nullable<T>
is defined as a normal struct, but there's special hooks within the CLR to box/unbox an instance of[mscorlib]System.Nullable`1
to null according to theHasValue
property. There's more details on this hereNullable<>
is a struct implemented within mscorlib.One special thing is in the C# compiler that recognizes
X?
as an alias forNullable<X>
.Here's the MSDN article on Nullable Types.
http://msdn.microsoft.com/en-us/library/1t3y8s4s(v=VS.100).aspx
I'm not sure what you're trying to get at with Nullable<>, unless you're mis-understanding that Nullable types are instances of the
System.Nullable<T>
struct.