使用Stopwatch对象,TimeSpan对象
Stopwatch sw = new Stopwatch();//跑表,该类可以进行时间的统计 命名空间using System.Diagnostics; sw.Start(); //跑表开始
//花费时间的目标 sw.Stop(); //跑表结束 TimeSpan ts = sw.Elapsed; //统计到的时间 Console.WriteLine(ts.Milliseconds); //输出统计到的时间的毫秒数
本文介绍了如何使用C#中的Stopwatch类来精确地测量代码执行所耗费的时间,并展示了如何输出统计到的时间的毫秒数。
使用Stopwatch对象,TimeSpan对象
Stopwatch sw = new Stopwatch();//跑表,该类可以进行时间的统计 命名空间using System.Diagnostics; sw.Start(); //跑表开始
//花费时间的目标 sw.Stop(); //跑表结束 TimeSpan ts = sw.Elapsed; //统计到的时间 Console.WriteLine(ts.Milliseconds); //输出统计到的时间的毫秒数
转载于:https://www.cnblogs.com/Sukie-s-home/p/5803176.html
4404

被折叠的 条评论
为什么被折叠?