I don\'t think it\'s possible but since I haven\'t got a definite clarity from MSDN, I feel that it\'s best to ask. Suppose that we have a class as follows.
The best we could to to ensure decimals serialized to 2 decimal places was tp:
var xmlAttributeOverrides = new XmlAttributeOverrides(); var ctrlSumAttributes = new XmlAttributes { XmlIgnore = true }; xmlAttributeOverrides.Add(typeof(Sepa.GroupHeader39), "CtrlSum", ctrlSumAttributes); var ser = new XmlSerializer( typeof( Sepa.Document ), xmlAttributeOverrides);
public partial class GroupHeader39 { [XmlElement("CtrlSum")] public string CtrlSumString { get => CtrlSum.ToString("F2"); set { /* required to work */ } } }
I hope this helps someone out with this issue.