public static complex operator +(complex c1, complex c2) { complex c3 = new complex(0, 0); c3.a = c1.a * c2.b + c2.a * c1.b; c3.b = c1.b * c2.b; return(c3); }
static void f2() { FileStream fs = new FileStream(@"C:\Users\acer\Desktop\lab pp2\data.xml", FileMode.Open, FileAccess.Read); XmlSerializer xs = new XmlSerializer(typeof(complex)); try { complex c1 = xs.Deserialize(fs) as complex; Console.WriteLine(c1); } catch (Exception e) { Console.WriteLine(e.Message); } finally { fs.Close(); } }
static void f1() { FileStream fs = new FileStream(@"C:\Users\acer\Desktop\lab pp2\data.xml", FileMode.Create, FileAccess.Write); XmlSerializer xs = new XmlSerializer(typeof(complex)); complex c1 = new complex(4, 5); try { xs.Serialize(fs, c1); } catch (Exception e) { Console.WriteLine(e.Message); } finally { fs.Close(); } Console.WriteLine("done"); }