2

You can assign a null to a nullable type variable like so:

bool? b = null

Nullable<T> is a value type so I assumed that this was done by overloading implicit conversion.

Here is the implementation taken from the .NET framework source code:

 public static implicit operator Nullable<T>(T value) {
        return new Nullable<T>(value);
    }

The type parameter T is restricted to a struct. So the argument value is restricted to value types and cannot be null.

I would like to know how and where the null assignment is handled.

Narek Margaryan
  • 334
  • 1
  • 4
  • 11

0 Answers0