In. NET 2.0, there is a new nullable type, which can be used to assign null values to the basic value type, such
Int? K = 3; // a value type that can be empty (empty for short)
Int M = NULL; // Error
Int? J = NULL; // success
From the above example, we can see that a value type that can be empty can be defined after the value type. in C #, is a value type added after the basic type? In VB. NET
DimDtmvarnameAsNullable (OfDatetime)
DimIntvarnameAsNullable (Of Integer)
DimBvarnameAsNullable (Of Boolean)
Note that the null type is not a new. NET data type.
In fact, the empty type is defined in the. Net Library as a type class system. nullable <t>, where T is the value type that can be replaced.
Int? K = 3; similarly, you can write system. nullable <int> K = 3;
The operations are implemented through the operator overloading of this class.
You can use hasvalue to determine whether the null type has been assigned a value.
If(Dtmvarname. hasvalue)
{
//... Do something
}