I have this code:
DateTime d = DateTime.Today;
long l = d.ToBinary();
object o = (long)l;
d = new DateTime((long)o);
When I execute this code, I get an error on d = new Date..
(the last line). It says the argument is out of range; that it is out of the range of max and min ticks. Which does seem probable, as using a debugger l
is a huge negative number(and I didn't think ticks could be negative).
Is C#'s object/long
broken or am I just missing something here? I've also tried setting the DateTimeKind
and that did nothing.
Also, this work is being done on a 64 bit machine.(though that shouldn't matter due to .NET)