日期时间转换为空值 [英] date time convert to null value

查看:414
本文介绍了日期时间转换为空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将日期时间转换为空值吗?
怎么样..
默认情况下,我的日期值为01/01/0001 12:00 AM.没有转换",整个术语都不适用.

由于这个问题尚不清楚,因此我给您一个相关的提示:看看可空类型.例如:

 System.DateTime时间= System.DateTime.Now; // 所有正确
//  time = null; //会导致编译错误

System.DateTime? nullableTime = System.DateTime.Now; // 所有正确
nullableTime = ; // 也可以;您可以在没有时间",从不",大爆炸之前"的意义上使用它:-) 



请阅读以下内容:
http://en.wikipedia.org/wiki/Nullable_type [ http://msdn.microsoft.com/en-us/library/1t3y8s4s%28v = VS.100%29.aspx [ ^ ].

另请参阅: http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx [ ^ ].

—SA


i want convert date time to null value?
how it is..
by default i got date value as 01/01/0001 12:00 AM..

解决方案

The question as it is formulated makes no sense at all. There is no "convert", the whole term is inapplicable.

As the question is absolutely unclear, I''ll give you one relevant hint: look at nullable types. For example:

System.DateTime time = System.DateTime.Now; //all correct
//time = null; //would cause compilation error

System.DateTime? nullableTime = System.DateTime.Now; //all correct
nullableTime = null; //fine, too; you can use it in the sense "no time", "never", "before Big Bang" :-)



Read about it:
http://en.wikipedia.org/wiki/Nullable_type[^],
http://msdn.microsoft.com/en-us/library/1t3y8s4s%28v=VS.100%29.aspx[^].

See also: http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx[^].

—SA


这篇关于日期时间转换为空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆