using System; using System.IO; using System.Collections; using System.Xml.Serialization; namespace ConsoleApplication4 { /// /// Summary description for Class1. /// class Class1 { /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { B bInstance = new B (); XmlSerializer s = new XmlSerializer (typeof (C)); Stream st = File.Create ("foobar.txt"); s.Serialize (st, bInstance.CInstance); st.Close (); StreamReader r = new StreamReader (File.OpenRead ("foobar.txt")); Console.WriteLine (r.ReadToEnd ()); r.Close (); } } public class B { C cInstance; public C CInstance { get { return cInstance; } } public B () { cInstance = new C (); cInstance.MyArray.Add ("foo"); cInstance.MyArray.Add ("bar"); cInstance.MyArray.Add ("dibididabada"); } } public class C { ArrayList m_arrayList = new ArrayList(); public ArrayList MyArray { get { return m_arrayList; } } } }