C# Stopwatch

using System.Diagnostics;
Console.WriteLine("Stopwatch starting ");
var stopwatch = new Stopwatch();
stopwatch.Start();
// Wait 10 seconds
Thread.Sleep(10000);
stopwatch.Stop();
TimeSpan elapsedTime = stopwatch.Elapsed;
Console.WriteLine("Stopwatch elapsedTime " + elapsedTime.ToString(@"m\:ss\.fff"));
Console.ReadLine();
view raw Stopwatch.cs hosted with ❤ by GitHub
 

 Output : 

Stopwatch starting 

Stopwatch elapsedTime 0:10.030

Yorumlar