c# - How to parse string with hours greater than 24 to TimeSpan? -
how parse string 30:15 timespan in c#? 30:15 means 30 hours , 15 minutes.
string span = "30:15"; timespan ts = timespan.fromhours( convert.todouble(span.split(':')[0])). add(timespan.fromminutes( convert.todouble((span.split(':')[1]))));
this not seem elegant.
if you're format "hh:mm" try this:
string span = "35:15"; timespan ts = new timespan(int.parse(span.split(':')[0]), // hours int.parse(span.split(':')[1]), // minutes 0); // seconds
Comments
Post a Comment