Exemple #1
0
        public static Complex_number operator /(Complex_number a, Complex_number b)
        {
            Complex_number c = new Complex_number();

            c.a = a.a / b.b;
            c.b = a.b / b.a;
            return(c);
        }
Exemple #2
0
        public static Complex_number operator *(Complex_number a, Complex_number b)
        {
            Complex_number c = new Complex_number();

            c.a = a.a * a.b;
            c.b = a.b * b.b;
            return(c);
        }
Exemple #3
0
        public static Complex_number operator +(Complex_number a, Complex_number b)
        {
            Complex_number c = new Complex_number();

            c.a = a.a + b.a;
            c.b = a.b + b.b;
            return(c);
        }
Exemple #4
0
        public void Save(Complex_number cn)
        {
            FileStream    fs = new FileStream("complex_numbers.xml", FileMode.Truncate, FileAccess.ReadWrite);
            XmlSerializer xs = new XmlSerializer(typeof(Complex_number));

            xs.Serialize(fs, cn);
            fs.Close();
        }
Exemple #5
0
        public static void F2()
        {
            FileStream     fs  = new FileStream("complex_numbers.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            XmlSerializer  xs  = new XmlSerializer(typeof(Complex_number));
            Complex_number cn1 = xs.Deserialize(fs) as Complex_number;

            Console.WriteLine(cn1 + cn1);
            fs.Close();
        }
Exemple #6
0
        public static void F1()
        {
            Complex_number cn = new Complex_number(12, 3);
            FileStream     fs = new FileStream("complex_numbers.xml", FileMode.Truncate, FileAccess.ReadWrite);
            XmlSerializer  xs = new XmlSerializer(typeof(Complex_number));

            xs.Serialize(fs, cn + cn);
            Console.WriteLine(cn + cn);
            fs.Close();
        }