问题描述
我想在C#程序中重置数据库的DateTime值,但似乎无法取消DateTime。有关如何执行此操作或是否如何重置DateTime值的任何建议?在此先感谢。
Hi, i want to reset DateTime values for my database in a C# program but it seems DateTime can't be nulled. Any advice on how to do it or if not how to reset the DateTime value? Thanks in advance.
推荐答案
System.DateType? myTime = null;
//...
if (myTime == null) //...
请参阅: [ ^ ]。
在语义上,看起来你补充了任何非可空类型的值集,只有一个额外的点:空值,就是全部。我不建议尝试使用重置值(如 default(System.DateTime)
)。默认值是有效的时间点,不能认为是没时间。不要使用它,更好地使用可空类型。
Please see: http://msdn.microsoft.com/en-us/library/1t3y8s4s%28v=vs.90%29.aspx[^].
Semantically, it looks like you complement the value set of any non-nullable type with one extra point: null value, that's all. I don't advise to try to use "reset value" (like default(System.DateTime)
). The default value is a valid point of time, it cannot be considered as "no time". Don't use it, better use the nullable type.
DateTime.MinValue
谢谢,
Nani。
Thanks,
Nani.
这篇关于C#中DateTime的空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!