2014-09-22 82 views

回答

1

爲了達到你的要求,請使用TimeSpan.FromMinutes如下圖所示: -

var result = TimeSpan.FromMinutes(80); 

TimeSpan.FromMinutes會給你一個對象,你可以以不同的方式使用,如下圖所示。

var hours = (int)result.TotalHours; 
var minutes = result.Minutes; 

var time = string.Format("{0} : {1}", hours, minutes); 
1

可以這樣進行簡單的計算mathemetical:

//minutes to be converted (70minutes = 1:10 hours) 
int totalminutes = 70; 
//total hours 
int hours = 70/60; 
//total minutes 
int minutes = 70 % 60; 
//output is 1:10 
var time = string.Format("{0} : {1}", hours, minutes);