我接收來自外部源的輸入,其中時間跨度字段以秒爲單位進行存儲。 來將這些轉換爲時間跨度我目前做這個如何顯示累積時間的TimeSpan?
TimeSpan.FromSeconds(140520)
這導致顯示1 15:02:00
我想什麼時間跨度的是,它顯示39:02:00
我怎樣才能做到這一點?
我接收來自外部源的輸入,其中時間跨度字段以秒爲單位進行存儲。 來將這些轉換爲時間跨度我目前做這個如何顯示累積時間的TimeSpan?
TimeSpan.FromSeconds(140520)
這導致顯示1 15:02:00
我想什麼時間跨度的是,它顯示39:02:00
我怎樣才能做到這一點?
所產生的時間跨度的TotalHours
物業應該給你你想要什麼第一部分:
var timespan = TimeSpan.FromSeconds(140520);
//If you cast the TotalHours to int you will get '39'
int totalHours = (int)timespan.TotalHours;
//If you want the '2' that would result from your input of 140520 you will need the minutes property
int minutes = timespan.Minutes;
重複的是確切的東西我一直在尋找,謝謝 – GuidoG