Ok, first two DateTimes have different Kind.
DateTime.Nowlooks like Local, the second is Kind Unspecified.
var now = DateTime.Now;
var timeA = now.ToBinary();
var dateB = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond, now.Kind);
var timeB = dateB.ToBinary();
Console.WriteLine(timeA);
Console.WriteLine(timeB);
This leads to different results:
-8588637530157241842
-8588637530157245808
Using ticks gives the correct results, but this is due to the fact that ticks use 100 nanosecond intervals, which are even more accurate than milliseconds.
Milliseconds are the smallest you can specify, but not the smallest internal variable.
var dateB = new DateTime(now.Ticks, now.Kind);
Davio source
share