The only way of having a variable which hasn't been assigned a value in C# is for it to be a local variable - in which case at compile-time you can tell that it isn't definitely assigned by trying to read from it :)
I suspect you really want Nullable<DateTime>
(or DateTime?
with the C# syntactic sugar) - make it null
to start with and then assign a normal DateTime
value (which will be converted appropriately). Then you can just compare with null
(or use the HasValue
property) to see whether a "real" value has been set.