-5

Round timespan seconds I also need do same with .Hours and .Minutes

This:

1.53994 second

to:

1 second
Ashkru
  • 1,495
  • 1
  • 17
  • 26
  • 6
    Wouldn't 1.53994 rounded be 2? – Chris Cruz Feb 22 '17 at 00:24
  • @Ashkru Did you even bother to look at the answers from the linked post? – Filburt Feb 22 '17 at 00:25
  • That is to round I was total second it is nothing like my question. – Ashkru Feb 22 '17 at 00:26
  • 1
    `TimeSpan.FromSeconds((int)(ts.TotalSeconds));`as shown in [this answer](http://stackoverflow.com/a/37722864/205233) rounds to full seconds *exactly like your question*. – Filburt Feb 22 '17 at 00:32
  • @Ashkru I would say edit your question and add the code sample for it so as to benefit the others. Also, please change the rounding of 1.53994 seconds to 2 seconds. Otherwise, the interpretation of the question itself will be wrong. – tRuEsAtM Feb 22 '17 at 01:14

1 Answers1

2

This code worked for me.

TimeSpan ts = TimeSpan.FromSeconds(1.54);
Math.Round(ts.TotalSeconds);
tRuEsAtM
  • 3,517
  • 6
  • 43
  • 83