title: C# XML Serialization and Decimal Value
body: <p>I am using XmlSerializer to serialize a C# object that contains a decimal to a string of xml</p>
  
  <p>e.g. </p>
  
  <pre><code>AnObject.ADecimalValue
  </code></pre>
  
  <p>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</p>
  
  <p><code>AnObject.ADecimalValue = decimal.Round(AnObject.ADecimalValue, 2);</code></p>
  
  <p>The serializing code is below.</p>
  
  <pre><code>   XmlSerializer serializer = new XmlSerializer(typeof(AnObject));
  
      using (StringWriter writer = new StringWriter())
      {
          serializer.Serialize(writer, source);
  
          string result = writer.ToString();
  
          return result;
      }
  </code></pre>
  
  <p><strong>How can I ensure only two values are output out after the decimal point</strong></p>