Nullable types - e.g. int?
- are value types that pack an extra boolean flag to indicate whether they have a value or not. A nullable type can also be compared with null to check if it contains a value or not:
int? ni = 10;
if(ni != null) { ... }
Suppose we box a null int?
:
int? ni = null;
object oni = ni; // box ni
Would a null int?
be boxed to an object on managed heap? You can answer that question by telling what would be the output of below:
Console.WriteLine( oni != null ? "Not Null" : "Null" );