How to parse string with hours greater than 24 to TimeSpan?

Posted by jlp on Stack Overflow See other posts from Stack Overflow or by jlp
Published on 2010-04-28T09:45:29Z Indexed on 2010/04/28 9:53 UTC
Read the original article Hit count: 905

Filed under:
|

How to parse string like 30:15 to TimeSpan in C#? 30:15 means 30 hours and 15 minutes.

string span = "30:15";
TimeSpan ts = TimeSpan.FromHours(Convert.ToDouble(span.Split(':')[0])).Add(TimeSpan.FromMinutes(Convert.ToDouble((span.Split(':')[1]))));

This does not seem too elegant.

© Stack Overflow or respective owner

Related posts about c#

Related posts about timespan