作用:

微软提供的常用于统计时间消耗的类,作为一个固定的API接口供大家使用。

 

先看代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;

namespace StopWatchDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            int icount = 0;
            for (int i = 0; i < 100000; i++)
            {
                for (int j = 0; j < 10000; j++)
                {
                    icount = i + j;
                }
            }

            stopwatch.Stop();

            Console.WriteLine(stopwatch.Elapsed.TotalMilliseconds);
        }
    }
}
View Code

相关文章:

  • 2022-12-23
  • 2021-12-26
  • 2021-12-19
  • 2021-06-08
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-28
  • 2021-12-15
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
相关资源
相似解决方案