10

ElapsedTicks & Elapsed.Ticks are properties of Stopwatch, which I think should be same. And in case they are same, why they should give different outputs ?

Code :

Stopwatch spwt = Stopwatch.StartNew();
spwt.Stop();
Console.WriteLine(spwt.ElapsedTicks);
Console.WriteLine(spwt.Elapsed.Ticks);

Output :

6
16

Why is this difference observed ? shouldn't it be same ?

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
Pratik
  • 11,534
  • 22
  • 69
  • 99
  • Does this answer your question? [Are StopWatch.ElapsedTicks and StopWatch.Elapsed.Ticks always the same?](https://stackoverflow.com/questions/1017608/are-stopwatch-elapsedticks-and-stopwatch-elapsed-ticks-always-the-same) – Wai Ha Lee Sep 29 '21 at 13:39

1 Answers1

14

See https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.stopwatch.elapsedticks#remarks :

Note

Stopwatch ticks are different from DateTime.Ticks. Each tick in the DateTime.Ticks value represents one 100-nanosecond interval. Each tick in the ElapsedTicks value represents the time interval equal to 1 second divided by the Frequency.

Pang
  • 9,564
  • 146
  • 81
  • 122
C.Evenhuis
  • 25,996
  • 2
  • 58
  • 72