4.1 What to do if there is no value
You want to set the datetime variable to NULL, but the compiler does not allow (a product has not been sold yet, there is no date of purchase)
4.1.1 Why a variable of value type cannot be null
For a variable of a reference type, its value is a reference, and the value of a value type variable is its own real data. It can be assumed that a non-null reference value provides a way to access an object. However, NULL is equivalent to a special value, which means that I do not reference any object.
4.1.2 Mode in c#1.0 that represents null values
- Magic Value (Datetime.minvalue)
- Reference type Wrapper
- Extra Boolean flag
4.2 System.nullable<t> and System.Nullable
Static Class System.nuallable provides a number of tool methods that simplify the use of nullable types.
4.2.1nullable<t> Introduction
Nullable<nullable<int>> is not allowed, even if the nullable<t> conforms to all characteristics of the value type in other respects. For any specific nullable type, the type of T is called the underlying type of the nullable type (underlying type). For example, the underlying type of,nullable<int> is int.
C # in Depth (fourth nullable type)