using System;
using System.Text;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
DateTime dt1 = new
DateTime();
DateTime? dt2=null
;
isDateTimeNull(dt1);
isDateTimeNull(dt2);
}
static void
isDateTimeNull(DateTime? dt)
{
if(dt.GetHashCode()==0)
{
Console.WriteLine("DateTime is unassigned");
}
}
}
}
Output:
In stackoverflow.com I found another way for checking null datetime
DateTime datetime = new
DateTime();
if (datetime == DateTime.MinValue)
{
//unassigned
}
This comment has been removed by a blog administrator.
ReplyDelete