c# only only 2 digits after decimal number double

107

c# only only 2 digits after decimal number double -

decimalVar.ToString("#.##"); // returns ".5" when decimalVar == 0.5m
or

decimalVar.ToString("0.##"); // returns "0.5"  when decimalVar == 0.5m
or

decimalVar.ToString("0.00"); // returns "0.50"  when decimalVar == 0.5m

Comments

Submit
0 Comments