将空值分配给datetime对象 [英] Assigning null value to datetime object
本文介绍了将空值分配给datetime对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能解释我如何在vb.net中为日期时间对象分配空值.
在此先感谢
Hi, can anyone explain me how to assign a null value to a datetime object in vb.net.
thanks in advance
推荐答案
Dim dt as DateTime = System.DBNull.Value
如果您使用的是.Net 2.0或更高版本,则始终可以使用可为空的类型.
将您的字段声明为DateTime? dt
;
然后设置dt = null
;
更新:
在VB.NET中,使用此命令:
If you are using .Net 2.0 or greater, you can always use a nullable type.
Declare your field asDateTime? dt
;
Then setdt = null
;
UPDATE:
In VB.NET, use this:
Dim dt As System.Nullable(Of DateTime)
dt = Nothing
这篇关于将空值分配给datetime对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文