Please enable Javascript to correctly display the contents on Dot Net Tricks!
C# Questions & Answers

What is Nullable Type?

Value types (like int, bool etc.) which accept either their normal values or a null value are referred as Nullable types. Nullable types are instances of the Nullable struct.

For example, A Nullable<bool> is pronounced as "Nullable of bool," and it can accept the values true, false or null.

Nullable types can also be defined using ? type modifier. This token is placed immediately after the value type being defined as nullable.

//assigning normal value
Nullable flag = true;
//OR
bool? flag = true;
//assigning normal value
Nullable x = 20;
//OR
int? x = 20;