(ignoring the optimized compiler flag )
can it be that this code will enter the block on some systems ?
if (Datetime.Now!=Datetime.Now)
{
...
}
I mean , how does it evaluate the values here ? (is it by order) ?
Is there any situations where the condition might be true ?
again , ignore the optimized flag.
The datetime precision specifies number of digits after the decimal dot and can be any integer number from 0 to 6. If no precision is specified it is assumed to be 0, for backward compatibility reasons. A datetime precision can be specified wherever a type name is used.
First, lets take a look at precision: The DateTime type is basically just a 64 bit integer that counts “ticks”. One tick is 100 nanoseconds (or 0.0001 milliseconds) long (MSDN). So DateTime 's precision can be up to 0.0001 milliseconds.
MySQL permits fractional seconds for TIME , DATETIME , and TIMESTAMP values, with up to microseconds (6 digits) precision.
DateTime
has a precision of 100ns. But on typical implementations, DateTime.Now
only changes every few milliseconds.
Datetime.Now != Datetime.Now
can be true, but it's extremely unlikely to happen. This is a typical race conditions of the kind you often see in multi-threaded code. i.e. you should not rely on DateTime.Now
not changing, but rather store a copy in a local variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With