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
Post a Comment