1
I have two variables:
TimeSpan horaI = new TimeSpan(10, 00, 00);
TimeSpan horaF = new TimeSpan(22, 00, 00);
I need to present them on the screen as follows 10:00 and 22:00. But I’m not getting it.
How could I do that?
1
I have two variables:
TimeSpan horaI = new TimeSpan(10, 00, 00);
TimeSpan horaF = new TimeSpan(22, 00, 00);
I need to present them on the screen as follows 10:00 and 22:00. But I’m not getting it.
How could I do that?
2
You can do it this way:
var horaI = new TimeSpan(10, 00, 00);
var horaFormatada = string.Format("{0:hh\\:mm}", horaI);
Of course there are several other ways to do this.
Source: https://msdn.microsoft.com/pt-br/library/ee372287(v=vs.110). aspx
Browser other questions tagged c# string type-conversion timespan
You are not signed in. Login or sign up in order to post.