c# - double.ToString("G") but always include point? -
is there formatting code assumes "g" formatting specification ensures decimal point shown?
for instance:
- 1 = "1.0"
- 123 = "123.0"
- 10000 = "1e+4"
or need use following:
string str = somedouble.tostring(); if (!str.contains('.') && !str.contains('e') && !string.contains('e')) str += ".0";
use can use n+count format count shows digit counts after . somedouble.tostring("n1")
Comments
Post a Comment