using System.IO;
using System;
class NullableType
{
static void Main(string[] args)
{
int ? myInt1 = 15;
int ? myInt2 = null;
if (myInt1 != null)
{
Console.WriteLine("Value of Nullable Type via != Comparision: {0}", myInt1);
}
if (myInt2.HasValue)
{
Console.WriteLine("Value of Nullable Type via HasValue Property: {0}", myInt2);
} else
{
Console.WriteLine("It contains Null Value");
}
}
}Output:
Value of Nullable Type via != Comparision: 15
It contains Null Value
