Use of nullable datatype.

Tripati.patro
Posted by Tripati.patro under C# category on | Points: 40 | Views : 1650
// Declaring a nullable variable
int? nullVariable;

// Assign null value to a nullable variable.
nullVariable = null;

// Assign datatype specific value to a nullable variable.
nullVariable = 100;

// Check for null value
if(nullVariable.HasValue)
{
// Use the nullable variable.
int actualVale = nullVariable.Value;
MessageBox.Show("Proper Value available");
}
else
{
MessageBox.Show("NULL value found");
}

Comments or Responses

Login to post response