是否有可用于 CLR 的高分辨率(微秒、纳秒)DateTime 对象? [英] Is there a high resolution (microsecond, nanosecond) DateTime object available for the CLR?

查看:28
本文介绍了是否有可用于 CLR 的高分辨率(微秒、纳秒)DateTime 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储微秒级时间戳的仪器,我需要存储这些时间戳作为从仪器收集信息的一部分.请注意,我确实需要生成时间戳;这些时间戳由仪器本身使用高分辨率实时操作系统预先生成.解析这些值不是问题——它们使用标准格式存储在 UTC 时间.最初我想使用 C# DateTime 结构 只能存储毫秒分辨率的时间戳.

I have an instrument that stores timestamps the microsecond level, and I need to store those timestamps as part of collecting information from the instrument. Note that I do not need to generate timestamps; these time stamps are pre-generated by the instrument itself using a high resolution real-time operating system. Parsing out these values is not an issue — they are stored using a standard format in UTC time. Originally I wanted to use the C# DateTime structure can only store time stamps up millisecond resolution.

.NET 或支持微秒和(理想情况下)纳秒分辨率时间戳的通用 C# 库是否提供了另一个对象,还是我必须自己推出?

Is there another object supplied with .NET or a common C# library that supports micro- and (ideally) nanosecond resolution timestamps, or am I going to have to roll my own?

推荐答案

毕竟你也许可以使用 DateTime.DateTime.Ticks 的分辨率为 100 纳秒.您可以使用 DateTime.AddTicks 设置刻度.

You might be able to use DateTime after all. DateTime.Ticks' resolution is 100 nanoseconds. You can set the ticks with DateTime.AddTicks.

这篇关于是否有可用于 CLR 的高分辨率(微秒、纳秒)DateTime 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆