c# - How to Convert Decimal to 2 fraction -


how convert decimal 2 fraction. example want convert 10.5234 10.52 , if fraction 0 disappear fraction , 4.3014 convert 4.3

you can use

string.format("{0:0.##}", mynumber); 

you can have @ custom numeric format strings documentation.

if use c#6.0 or above, can use string interpolation this:

$"{mynumber:0.##}" 

as suggested jeppe stig nielsen


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -