DateTime startTime = DateTime.Now; do somethings DateTime endTime = DateTime.Now; TimeSpan totalTimeTaken = endTime - startTime;
System.Diagnostics.Stopwatch
var stopWatch = new Stopwatch(); stopWatch.Start(); //do somthing here stopWatch.Stop(); var 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);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)