在程序的main()方法中第一句写 获取现在的时间,程序的最后一句也写 获取现在的时间,
用后面一个时间减去前面一个时间就得到程序运行的时间

解决方案 »

  1.   

    stopwatch w = new stopwatch();
    w.start();
    ...
    w.stop();
    console.writeline(w.ellapsedmilliseconds);
      

  2.   

    我是想在label中顯示程式運行的時間
    你以上的代 碼要怎麼使用?
    w.stop()要放在哪裡去
      

  3.   

    using System.Diagnostics;Stopwatch w;
    long sec = 0;
    w = Stopwatch.StartNew();// put the code you want to calculate the executing time here.sec = w.ElapsedMilliseconds;
    //Response.Write(sec.ToString());