AS we all know there are two different types in C#
•Refrence type
•Value type
Reference type can be represent as non existent value (NULL) but Vaue type , however cannot represent NULL value.
For e.g
Since String is reference type you can declare it as null
String s=null; //ok
But if you try to declare value type such as Int32 to null it produceses compiler error
Int32 i=null; // compiler error
To represent null in a value type, you must use a special construct called a nullable type. It is represented using ? symbol.
Int32? I=null; //now its ok
Now scenario when nullable types commanly used is in database programming where calss is map to table with nullable columns.
• If the columns are reference type that is String such as (email address and customer address), there is not a problem as you can defined it as null in C#
• But if the columns are value type that is double such as (customer account balance), you cannot map it to C# without using nullable types.
For e.g
// maps to a Customer table in a database
public class Customer
{
...
public decimal? AccountBalance;
}