C#计时器代码

C#写计时器:

System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start();//开始计时
       
int count=0;
for (int i = 0; i < 10000; i++)
{
count++;
}
watch.Stop();//停止计时

Console.WriteLine("共耗时:" + (watch.ElapsedMilliseconds));//输出时间--毫秒

Console.ReadKey();

posted @ 2020-12-17 08:57  五点  阅读(906)  评论(0编辑  收藏  举报