search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

[C#基礎]-C# 取得程式執行時間差 – jashliao部落格

[C#基礎]-C# 取得程式執行時間差


本篇要分享C# 取得程式執行時間差範例,有興趣的同好,歡迎來一下哈哈 ^ ^。
拷貝來源:http://msdn.microsoft.com/zh-tw/library/system.diagnostics.stopwatch.aspx

using System;
using System.Diagnostics;
using System.Threading;
class Program
{
static void Main(string[] args)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Thread.Sleep(10000);
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
        TimeSpan ts = stopWatch.Elapsed;
// Format and display the TimeSpan value.
        string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("RunTime " + elapsedTime);
}
}

 



熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦