1
我想xml序列化包含其他自定義對象的自定義對象。我這樣做,但它不會工作。如何在c#中序列化包含其他類的對象的對象?
class A()
{
public B b;
}
class B()
{
public int a;
}
System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(A));
XmlAttributes xmlAttributes = new XmlAttributes();
System.IO.StreamWriter file = new System.IO.StreamWriter( @"d:\SerializationOverview.xml");
writer.Serialize(file, new A());
file.Close();
結果是:
<A>
</A>
哦,我不能相信的時候我沒有注意到:d,感謝ü非常 –