Use Nullable Type
Use of Nullable Type, New Feature in dotNet2.0
Declare the variable as Nullable, If you want to see whether value is assigned or not.
e.g. Nullable
Nullable types is having hasvalue and value members
e.g.
if (myvalue.HasValue)
{
//DO something
}
Null able type feature of .net is used for the accepting null Value
It enable us for giving reference type as null.
So by getting null value compiler do not terminate the program but continue it.
eg.
int? numone=null;
if (numone.HasValue==true)
{
Console.WriteLine("The Value Of Numone="+numone);
}
else
{
Console.writeLine("The Value Of Numonw : null");
}
In the above code "?" sign tells that it's of null-able type
When Above code compile in the Compiler then the OUTPUT is
""Value Of Numone: null""