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

python - RuntimeError: can't re-enter readline -

python - PyInstaller UAC not working in onefile mode -

php - Need to store a large amount of data in session with CI 3 but on storing large data in session it is itself destorying automatically -