From a XML file I receive decimals on the format:
1.132000
6.000000
Currently I am using Decimal.Parse like this:
decimal myDecimal = Decimal.Parse(node.Element("myElementName").Value, System.Globalization.CultureInfo.InvariantCulture);
-
How do print myDecimal to string
to look like below ?1.132 6
I don’t think there are any standard numeric format strings which will always omit trailing insignificant zeroes, I’m afraid.
You could try to write your own decimal normalization method, but it could be quite tricky. With the
BigIntegerclass from .NET 4 it would be reasonably feasible, but without that (or something similar) it would be very hard indeed.EDIT: Okay, I think this is what you want: