TDOR,
It's not a matter of DateTime being a complex type (which I don't know
what you mean by that), but rather, it is a value type, and value types can
not be null.
In the new version of .NET, there will be a structure introduced called
Nullable<T>, which is a generic. It will have a HasValue property, which if
true, means that the Value property returns a value. If it is false, then
the value is considered to be null.
Also, there will be new syntax in the language to handle this.
Basically, to have a nullable of any value type, you add ? after the type,
like so:
// Declare a nullable integer type.
int? pintNullableInt = null;
In this case, pintNullableInt.HasValue will return false. If you have
the community preview of VS.NET 2005, you can try it now.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"TDOR" <tj*****@hotmail.com> wrote in message
news:12**************************@posting.google.c om...
I am used to initilize vars with Null to mean undefined, but in c#
even complex types such as DateTime are considered value-types
so they cant be null. So far I have worked around the problem
using values that are outside the normal working range of my
programs or some other workaround, but in many places it turns
my code into an obscure piece of sh*t code! It make the code look
old fashion C, and not very nice to hand over to some other programmer
for maintainance. Anyone has a solution? - my books mention nothing of
this issue so its probably so simple it staring me stright in the face.