有一個主類有2個子類(每個代表獨立的實體),所有類都需要序列化。我該如何繼續? 我的要求是當我選擇MainClass時,我應該爲每個子類和主類獲取xml。在此先感謝......如果我的做法是不正確......正確的,以及..對象及其包含對象的序列化
下面給出防爆...
class MainClass
{
SubClass1 objSubclass1 = null;
SubClass2 objSubclass2 = null;
public MainClass()
{
objSubclass1 = new SubClass1();
objSubclass2 = new SubClass2();
}
[XmlElement("SubClass1")]
public SubClass1 SubClass1 {get {return objSubclass1;} }
[XmlElement("SubClass2")]
public SubClass2 SubClass2 {get {return objSubclass2;} }
}
Class SubClass1
{
Some properties here...
}
Class SubClass2
{
Some properties here...
}