环境:net framework 4.5.2


    1. using System.Diagnostics;
    2. Stopwatch st = new Stopwatch();
    3. //重置
    4. st.Reset();
    5. //开始
    6. st.Start();
    7. //停止
    8. st.Stop();
    9. //转毫秒
    10. Console.WriteLine(st.ElapsedMilliseconds.ToString() + " ms");