gpt4 book ai didi

c# - 秒表的 Elapsed Ticks 属性差异

转载 作者:太空狗 更新时间:2023-10-29 17:47:01 29 4
gpt4 key购买 nike

ElapsedTicks & Elapsed.Ticks 是 Stopwatch 的属性,我觉得应该是一样的。如果它们相同,为什么它们应该给出不同的输出?

代码:

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

输出:

6
16

为什么会出现这种差异?不应该一样吗?

最佳答案

参见 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.

关于c# - 秒表的 Elapsed Ticks 属性差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7432735/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com