Is there a high resolution (microsecond, nanosecond) DateTime object available for the CLR?

前端 未结 6 1354
情深已故
情深已故 2020-12-08 05:02

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

6条回答
  •  不知归路
    2020-12-08 05:34

    You could probably roll your own in various ways.

    1.) Create a structure using System.Decimal field as the "backing store".

    2.) Create a structure using System.Numerics.BigInteger as backing.

    Wrap methods to use System.DateTime for convenient "Parts" (year, month, day,...) Include your own Nanonsecond, Picosecond, Femtosecond, etc., properties and methods.

    FYI:

    DateTime.MaxValue.Ticks : 3,155,378,975,999,999,999

    Decimal.MaxValue : 79,228,162,514,264,337,593,543,950,335

    BigInteger : Arbitrarily Large!

提交回复
热议问题