Is it possible to output no more than two decimal places using Double.ToString ?

10.2345 โ†’ "10.23" 10.0 โ†’ "10" 10.20 โ†’ "10.2" 100 โ†’ "100" 

If so, how?

    1 answer 1

    Yes, like this:

     lCurrentTime.Text = String.Format("{0:0.00}", ((double)duration)); // ั‚ัŒั„ัƒ, ัั‚ ะฝะต ั‚ะพ 

    Better this way:

     string result = duration.ToString("#.##");