c# - Convert TimeSpan to Double -


i'm having trouble convertion of timespan double. that's code used convert double value timespan:

int r = 150; string t = timespan.fromhours(convert.todouble(r)).tostring(@"dd\.hh\:mm\:ss"); 

it gives:

t--> 6.06:00:00

now need retrieve value (150) timespan (6.06:00:00).

you need total-hours given timespan?

double totalhours = t.totalhours; 

so don't convert timespan string store timespan.

timespan.totalhours:

gets value of current timespan structure expressed in whole , fractional hours.

if have string 6.06:00:00 , want number of hours, parse first timespan:

timespan ts = timespan.parse("6.06:00:00"); double hours = ts.totalhours; 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -