Nullable Types in plain English…

Suppose we are writing a program and we declare a variable 

 int TotalAvailability;

As we know every primitive data type has a default value. But what if we dont want any value not even default value.

Now, the question comes into our mind: How can we store null value  as a default value into a primitive data type?

The answer is using  System.Nullable<T> types.

It is very useful, suppose we are creating an Employee class and want to define a property “TerminationDate” which stores the termination date of the employee. But if we dont make it nullable then the object of employee class will always return some value. To avoid that we can simply use:  

public Nullable<DateTime>  TerminationDate;  or  public DataTime? TerminationDate;

And to check whether the field has null value or not:

if(Employee1.TerminationDate.HasValue ){




Continue ReadingNullable Types in plain English…