I want to format a string as a decimal, but the decimal contains some following zeros after the decimal. How do I format it such that those meaningless 0\'s disappear?
double a = 1100.00
double b =1100.1
double c = 1100.100
double d =1100.1000
Remove last zero after point
string stra = a.toString("0.00").TrimEnd('0').TrimEnd('.');
string strb = b.toString("0.00").TrimEnd('0').TrimEnd('.');
string strc = c.toString("0.00").TrimEnd('0').TrimEnd('.');
string strd = d.toString("0.00").TrimEnd('0').TrimEnd('.');
Output
1100
1100.1
1100.1
1100.1