A Type Background

From a type perspective, you can draw the parallel to array types and generic types as type constructors. Given a type, another type can be constructed thanks to out-of-the-box runtime and language facilities. For nullable value types, that’s the case, too, but with some restrictions. As the name implies, they’re only supported over value types, but it’s also impossible to “nest” them, as in int?? or Nullable<Nullable<int>>.

The top part of Figure 4.40 shows the principle of a type constructor. Given any type T, as indicated by the dotted-lined box, a more complex type can be created. In this example, it’s a Nullable<T> type that provides a box around the original type with the HasValue and Value properties on it. At the bottom, ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.