using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Threading;
namespace ConsoleApp9
{
class Program
{
static void Main(string[] args)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// 让线程暂停5秒(5000毫秒)
Thread.Sleep(5000);
stopwatch.Stop();
// 获取运行时间
TimeSpan ts = stopwatch.Elapsed;
// 格式化并显示时间
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("Time: " + elapsedTime);
Console.ReadLine();
}
}
}