c# - Stopwatch elapsed output -


i had code crunched lot of data, started on thursday , left running on weekend. on monday, have come , seen finished. used stopwatch function track length of time code ran for. however, ended

elapsed: 2.18:57:55.xxx 

i understand it's output h:m:ss, don't understand first digit, since it's been running days. did convert hours days? did leave running long broke?

edit: sorry, didn't mean finished on monday. meant monday (when returned computer), done.

yes - that's format of timespan.tostring:

the returned string formatted "c" format specifier , has following format:

[-][d.]hh:mm:ss[.fffffff]

elements in square brackets ([ , ]) may not included in returned string. colons , periods (: and.) literal characters. non-literal elements listed in following table. note string returned tostring() method not culture-sensitive.

since there's not format specifier shows total hours, you'll need calculate it. if want hours shown single number use:

timespan ts = new timespan(2,18,57,55);  var output = string.format("{0}:{1}",                            ts.days*24 + ts.hours,                            ts.tostring("mm\\:ss\\.ffff"));  //output =  `66:57:55.0000` 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -