software master at the intersection of technology, science and art



nullable types

Under many circumstances a property or variable may be a value type which can be null. Previously defining a value type precluded the ability to assign null to it. For example, int b - b can not be null. However, the real world is different. With nullable types, you can permit a value type to be null. There are two way to indicate the nullable type. For example with int -

int ?
Nullable <int>

The ? marks that the int is nullable. Nullable <int> is an example of generics, an instance of the System.Nullable<T>. int? is a short hand which actually creates the Nullable class. This is most often useful in database properties.