请问如何把两个时间的差写成几分几秒的格式?怎么控制一个数字的小数位?
我计算了一个持续时长(Now - StartTime).TotalMinutes)
这需要再计算分钟和秒,而且秒的小数位太长。
用timespan 数据类型
-
分种 = difference.Minutes
-
秒 = difference.Seconds
控制小数位 : 用 Math.Round
应该是这样
Main1.xaml (10.3 KB)
1. totalMinutes = difference.TotalMinutes (157.633333....)
2. seconds = totalMinutes Mod 1 (0.6333....)
3. seconds = Math.Round(seconds * 60, 2) (38)
4. totalMinutes = Math.Floor(totalMinutes) (157)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.