A Nullable is a class that can represent the normal range of values for its underlying value type, plus an additional null value. For example, Nullable<NsBool> can be assigned a boolean value or it can be assigned the null value, meaning "not assigned".

Nullables have the following main methods:

  • HasValue: indicates if a valid value or a null is stored
  • GetValue: gets the stored value for its underlying type. This method assumes that a valid value is stored, so the programmer can check before calling it if HasValue is true.

Nullables can be constructed from an undelying type value, and can be compared and assigned against the type value or nullables of the same type.


Nullable<NsInt> a;
a.HasValue(); // Returns false

Nullable<NsInt> b(1234);
b.HasValue(); // Returns true
b.GetValue(); // Returns 1234
b == 1234; // true
b != 1234); // false
b == a; // false

Nullable<NsInt> c;
c = 1234;
c == b; // true

Type Converter

Nullables have an associated Type Converter called Nullable Converter to allow converting between types

© 2017 Noesis Technologies