Hi,
The DateTime data type is a value type and not reference
type.
For more information about value types and reference
types, look at these url's
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/csref/html/vcrefvaluetypes.asp
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/csref/html/vcrefvaluetypes.asp
The bottom line is, the value type cannot hold null
values unlike reference types.
So the work arounds which i can think of is to,
1) Assign a date like 1/1/1900 which will be considered
as null.
2) Create a class which has a field of type date. This
can be done in a smart way, such that you use it like a
normal value type, i.e., you don't need to use 'new' to
create the instance of the class.
This can be acheived by using implicit operator.
Thus, you get the ease of use of value type and also for
types like date you can assign null value since the class
is a reference type.
Hope this helps!!
Regards,
Madhu
MVP | MCSD.NET
-----Original Message-----
why doesn't c# seem to support some kind of 'null date'
for instance:
i have an application where the user is not obliged to
enter a date untilan event happens (e.g. a bug was fixed on xyz)
the calendar control in asp.net doesn't seem to have a
selectedDate = nullproperty
is there any way around this?
--
#-)
.