How show minutes and seconds with Stopwatch()

前端 未结 7 565
北荒
北荒 2021-02-01 12:20

I need to show also the minutes, actually I use this code for show the seconds, but also need the minutes

TimeSpan ts = stopwatch.Elapsed;
Console.WriteLine(\"F         


        
7条回答
  •  情深已故
    2021-02-01 13:17

    Review the documentation for TimeSpan, the struct returned by stopwatch.Elapsed. You want either the Minutes or TotalMinutes property.

    If you're measuring a 62 minute span, ts.Minutes will return 2, and ts.TotalMinutes will return 62.

提交回复
热议问题