Xamarin, Android

int Climb = 250; 

The SetText method displays the value 250 (time in seconds)

 _ComparePlaneLeftTextClimb.SetText(planesleft[e.Position].Climb.ToString(), TextView.BufferType.Normal); 

How to make the output displayed minutes and seconds? For example instead of 250 (seconds) 4:10?

    1 answer 1

    To work with time intervals you need to use System.TimeSpan

     int сlimb = 250; TimeSpan timeSpan = TimeSpan.FromSeconds(сlimb); string timeToShow = timeSpan.ToString(@"mm\:ss"); 
    • thank. And please tell me how to use the timespan string in my SetText method? - Bogdan Ilkiv
    • Instead of planesleft[e.Position].Climb.ToString(), use timeToShow , apparently - Bulson
    • happened. Only with option 4 minutes and 5 seconds is 4: 5 displayed. How can you make 4:05? - Bogdan Ilkiv
    • timeSpan.ToString(@"mm\:ss"); - Bulson 7:27 pm