471,055 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,055 software developers and data experts.

Empty DateTime Value

Hi all,

Does anyone know of a GOOD explaination why the DateTime type is a value
time (cannot be null) and furthermore does not provide a DateTime.Empty
value?

when using a DateTimePicker control on windows forms, there is the checkbox
that can indicate an empty date value. there is no such thing for the data
type DateTime.

Picho
Jul 21 '05 #1
5 14077
On Wed, 3 Dec 2003 15:09:23 +0200, "Picho" <pi***********@telhai.ac.il> wrote:

¤ Hi all,
¤
¤ Does anyone know of a GOOD explaination why the DateTime type is a value
¤ time (cannot be null) and furthermore does not provide a DateTime.Empty
¤ value?
¤
¤ when using a DateTimePicker control on windows forms, there is the checkbox
¤ that can indicate an empty date value. there is no such thing for the data
¤ type DateTime.

Because DateTime objects either contain a value or if unassigned are equal to Nothing.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #2
Paul Clement <Us***********************@swspectrum.com> wrote:
Because DateTime objects either contain a value or if unassigned
are equal to Nothing.


There's no way a DateTime can be equal to Nothing, because Nothing is a
reference value, and DateTime isn't a reference type. If a DateTime
variable is unassigned, it's simply unassigned and (at least in C#) you
can't use it at all - and I'd hope that's true in other languages. If
it weren't, I'd expect the value to be the same as that of
new DateTime().

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3
Jon,
There's no way a DateTime can be equal to Nothing, because Nothing is a
reference value, and DateTime isn't a reference type.


Actually, it can. Nothing, unlike null, is considered equal to the
default value of any type. 0, 0.0, false or null references.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #4
Mattias Sjögren <ma********************@mvps.org> wrote:
There's no way a DateTime can be equal to Nothing, because Nothing is a
reference value, and DateTime isn't a reference type.


Actually, it can. Nothing, unlike null, is considered equal to the
default value of any type. 0, 0.0, false or null references.


Blech. I stand corrected and appalled, both at the same time.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #5
"Picho" <pi***********@telhai.ac.il> wrote in message
news:uh**************@TK2MSFTNGP09.phx.gbl...
Does anyone know of a GOOD explaination why the DateTime type is a value
time (cannot be null) and furthermore does not provide a DateTime.Empty
value?


You could make the same argument for int. I imagine the answer lies in the
underlying implemenation of the type as a scalar, which is atomically
manipulated at the processor level.

-- Alan
Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Cyrus D. | last post: by
9 posts views Thread by news.microsoft.com | last post: by
4 posts views Thread by Frank Meng | last post: by
5 posts views Thread by Picho | last post: by
4 posts views Thread by Arpan | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.