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?
string.Format("{0}", 1100M);
string.Format("{0}", 1100.1M);
string.Format("{0}", 1100.100M);
string.Format("{0}", 1100.1000M);
displays:
1100
1100.1
1100.100
1100.1000
but I want it to be:
1100
1100.1
1100.1
1100.1
For reference, here are other questions that are essentially duplicates of this, that I've found thanks to answers given here: