Hey! I am trying to change a number of seconds in to a proper time stamp format. Like I do this to change 180 to 03:00
private void writeTime(int tempo)
{
TimeSpan otempo = new TimeSpan(0, 0, tempo);
string minutos = ((otempo.Minutes <= 9) ? "0" : "") + otempo.Minutes.ToString();
string segundos = ((otempo.Seconds <= 9) ? "0" : "") + otempo.Seconds.ToString();
label1.Text = minutos + ":" + segundos;
centrarLabel();
}
This does give me 180 into a proper format. I just want to know if there is a simpler way. This function might be called many many times and I don't want to create a new instance of TimeSpan every single time as I think this might pose a problem with memory etc. I tried using the DateTime class but... I just simply don't see how I can pass it the seconds and it gives me the proper format :(
I am not that great with c#. I am really trying to learn :) Thanks