DateTime比较的问题

 entity.WordDate =(System.DateTime)dr["WordDate"];//值是9999-12-31 23:59:59

DateTime.MaxValue

if(entity.WordDate ==DateTime.MaxValue)//false

{

}
貌似ToDateTime方法只能转换精确到秒的时间字符串,毫秒级的时间字符串系统抛出异常,说没有匹配的转换格式。

if(entity.WordDate.ToShortDateString() ==DateTime.MaxValue.ToShortDateString() )//false

{

}

原文地址:https://www.cnblogs.com/aaa6818162/p/1935262.html