By using C# built-in API
System.DateTime.Now.Millisecond
I can generate milliseconds.
But When I think about
I could not find any built-in functions from
System.DateTime
Could anyone give me suggestion please?
By using C# built-in API
System.DateTime.Now.Millisecond
I can generate milliseconds.
But When I think about
I could not find any built-in functions from
System.DateTime
Could anyone give me suggestion please?
Given that the resolution of the date/time is only ten milliseconds, it's probably considered unnecessary to try and have properties containing anything with a smaller resolution than one millisecond.
The values for them would simply be the milliseconds value with some zeros tacked on the end.
Computers have come a long way since mid last century but, given that a photon running at the speed limit of the universe(a) will only cross a few hydrogen atoms in one attosecond, it's a stretch trying to imagine how useful such a resolution would be.
A (classic) CPU running at 5GHz would only get through five billionths of an instruction in that timeframe.
(a) One of my favorite quotes: The speed of light. It's not just a good idea, it's the law.
For high resolution timing, you could look into the QueryPerformanceCounter function. I think it's also exposed via the Stopwatch
class in C#. Of course, this is only a timer, not a walltime, so you'll have to combine it with DateTime
to get actual timestamps.
SO1416139 has details on how to do that.
The smallest time unit on the Windows platform is the millisecond. You are not going to get any more accurate than that.
The smallest unit of time is the tick, which is equal to 100 nanoseconds. A tick can be negative or positive.
The most accurate you can get are ticks, which are 100 nano second amounts (0.1 Microseconds). You can access this via the Ticks property of a DateTime field, which is the number of ticks since 1 Jan 0001
There is no direct methods available to get this..need to write our own method to get this...see this url 1) http://www.dotnetperls.com/convert-nanoseconds 2) C# time in microseconds
Thanks, Snoby