private static void DeSerialize() { FileStream fss = new FileStream("complex.xml", FileMode.Open, FileAccess.Read); XmlSerializer xs = new XmlSerializer(typeof(ComplexNumbers)); ComplexNumbers cmplx = xs.Deserialize(fss) as ComplexNumbers; cmplx.PrintInfo(); fss.Close(); }
private static void Serialize() { ComplexNumbers cmplx = new ComplexNumbers(); cmplx.a = Convert.ToInt32(Console.ReadLine()); cmplx.b = Convert.ToInt32(Console.ReadLine()); FileStream fs = new FileStream("complex.xml", FileMode.OpenOrCreate, FileAccess.Write); XmlSerializer xs = new XmlSerializer(typeof(ComplexNumbers)); xs.Serialize(fs, cmplx); fs.Close(); }