Are nullable types reference types?

No, a nullable is a struct. What is happening is that the nullable struct has two values:

  1. The value of the data type (int for int?, DateTime for DateTime?, etc.).
  2. A boolean value which tells if the data type value has been set. (HasValue is the property.)

When you set the value of the data type, the struct changes HasValue to true.

Nullable types (C# Programming Guide)

Leave a Comment