Information Technology Reference
In-Depth Information
For example, the following code declares a variable of the nullable int type. Notice that the
suffix is attached to the type name—not the variable name.
Suffix
int? MyNInt = 28;
The name of the nullable type includes the suffix.
With this declaration statement, the compiler takes care of both producing the nullable
type and the variable of that type. Figure 23-3 shows the structure of this nullable type. It con-
tains the following:
￿
An instance of the underlying type
￿
Several important read-only properties:
-Property HasValue is of type bool and indicates whether the value is valid.
-Property Value is the same type as the underlying type and returns the value of the
variable—if the variable is valid.
Figure 23-3. A nullable type is the result of enclosing the underlying type in a struct, with two read-
only properties.
Search WWH ::




Custom Search