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 -

python - Error: Unresolved reference 'selenium' What is the reason? -

asp.net ajax - Jquery scroll to element just goes to top of page -