以下是我的xml序列化对象的一部分。
private decimal tOAMOUNTField;
public decimal TOAMOUNT
{
get
{
return this.tOAMOUNTField;
}
set
{
this.tOAMOUNTField = value;
}
}
XmlSerializer xsSubmit = new XmlSerializer(typeof(MyClassObject));
var entity = new Myobject();
entity .TOAMOUNT = 2.22M;
using (StringWriter sww = new StringWriter())
{
using (XmlWriter writer = XmlWriter.Create(sww))
{
// sww.WriteLine(@"<?xml version=""1.0"" encoding=""UTF-8""?>");
xsSubmit.Serialize(writer , entity);
output = sww.ToString();
}
}
上面提到“ToAmount”属性未按XML进行序列化
请指出错误,因为所有其他属性都在序列化
答案 0 :(得分:0)
您正在使用MyClassObject类型初始化XmlSerializer对象。
XmlSerializer xsSubmit = new XmlSerializer(typeof(MyClassObject));
但是正在序列化'Myobject()'对象。 尝试更改它:
XmlSerializer xsSubmit = new XmlSerializer(typeof(Myobject));