static void Main(string[] args) { Console.WriteLine("Hello world"); var tbs = new Perc(); tbs.d.init(); var yem1 = new Yem(); yem1.a = 777; var yem2 = new Yem(); yem2.a = 666; tbs.d.Add(yem1); tbs.d.Add(yem2); Perc readin; DataContractSerializer ser = new DataContractSerializer(typeof(Perc)); string output = JsonConvert.SerializeObject(tbs); using (FileStream fs = new FileStream(@".\a.xml", FileMode.Create)){ XmlTextWriter writer = new XmlTextWriter(fs, Encoding.ASCII); writer.Formatting = System.Xml.Formatting.Indented; ser.WriteObject(writer, tbs); writer.Close(); } using (FileStream fs = new FileStream(@".\a.xml", FileMode.Open)) { XmlTextReader reader = new XmlTextReader(fs); readin = (Perc)ser.ReadObject(reader, true); } Console.ReadLine(); }
public int CompareTo(object obj) { Yem that = obj as Yem; return(this.a.CompareTo(that.a)); }