C# XML Serialization and Decimal Value
问题 I am using XmlSerializer to serialize a C# object that contains a decimal to a string of xml e.g. AnObject.ADecimalValue I am finding the precision is varying in particular even if I explicitly round as below some values are getting output with four values after the point e.g. 12564.39 gets output as 12564.3900 AnObject.ADecimalValue = decimal.Round(AnObject.ADecimalValue, 2); The serializing code is below. XmlSerializer serializer = new XmlSerializer(typeof(AnObject)); using (StringWriter