コード例 #1
0
 public static TimeSpan GetDuration()
 {
     if (_running)
     {
         StopWatchException.NotStoppedExeption();
     }
     if (_start == _stop)
     {
         StopWatchException.NotStartedException();
     }
     return(_stop - _start);
 }
コード例 #2
0
 public static void DisplayAll()
 {
     if (_running)
     {
         StopWatchException.NotStoppedExeption();
     }
     Console.WriteLine("-----------------------------------");
     Console.WriteLine($"started: {_start}");
     for (int i = 0; i < _lapTimes.Count; i++)
     {
         Console.WriteLine($"lap {i + 1}: {_lapTimes[i]}");
     }
     Console.WriteLine($"stopped: {_stop}");
     Console.WriteLine($"full duration was: {GetDuration()}");
     Console.WriteLine("-----------------------------------");
 }