From .net 8.0 the can retrieve DateTime.Now.MicroSecond directly,but when you use the classic .net framework it does not work at all.
I'll show a round via Ticks of DateTime,to compare and validate my assumption i developed in .net 8
static void Main(string[] args) { DateTime dt = DateTime.Now; var milliDt=new DateTime(dt.Year, dt.Month, dt.Day,dt.Hour,dt.Minute,dt.Second,dt.Millisecond); var dtTicks = dt.Ticks; var milliTicks = milliDt.Ticks; var microSecond = (int)((dtTicks - milliTicks) / 10); Console.WriteLine($"MicroSecond via ticks:{microSecond}"); Console.WriteLine($"Microsecond:{dt.Microsecond}"); Console.WriteLine("Hello, World!"); }
标签:retrieve,C#,Ticks,DateTime,microsecond,WriteLine,var,dt From: https://www.cnblogs.com/Fred1987/p/18362445