I\'m curious to know how the Nullable type works behind the scenes. Is it creating a new object(objects can be assigned null) with a possible value of null?
In the
It's actually quite simple. The compiler gives you a hand with the syntax.
// this
int? x = null;
// Transformed to this
int? x = new Nullable()
// this
if (x == null) return;
// Transformed to this
if (!x.HasValue) return;
// this
if (x == 2) return;
// Transformed to this
if (x.GetValueOrDefault() == 2 && x.HasValue) return;