DateTime and Null value in C#

Assume that you want a variable of type DateTime and you would like to have the uninitialized value or null value , you can use the nullable DateTime type.

DateTime and Null value in C#

When you define a DateTime variable and dont initialize it , the default value is the DateTime.MinValue. You can simply define the type as Nullable DateTime as shown in the code snippet.

using System;

namespace AbundantcodeConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime ?dateValue = null;
            Console.WriteLine(dateValue.ToString());
            Console.ReadLine();
        }
    }
}