Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi when Iam using TimeSpan.Totalhours Iam getting some times hours like 23.5686565 so how can I round it to 23.56
Posted

If you are doing this for presentation purposes, you're better off using the following format specifier:


C#
TimeSpan.TotalHours.ToString("N2")
 
Share this answer
 
Look at the Math.Round[^] method - but your example is not "traditionally" rounded - that would give 23.57 not 23.56.
You may want to use Math.Truncate[^] on the value multiplied by 100.0 and then divided again.
 
Share this answer
 
try this
Math.Floor(23.5686565)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900