public static NumberAdder operator+(NumberAdder first, NumberAdder second)
        {
            NumberAdder res = new NumberAdder();

            res.Width  = first.Width + second.Width;
            res.Height = first.Height + second.Height;
            return(res);
        }
        public static NumberAdder operator-(NumberAdder first, NumberAdder second)
        {
            double      w   = first.Width - second.Width;
            double      h   = first.Height - second.Height;
            NumberAdder res = new NumberAdder(w, h);

            return(res);
        }
Пример #3
0
        private static void TestNumberAdder()
        {
            double      w1 = 10, h1 = 5;
            double      w2 = 30, h2 = 15;
            NumberAdder adder1, adder2;

            adder1 = new NumberAdder(w1, h1);
            adder2 = new NumberAdder(w2, h2);
            NumberAdder _add  = adder1 + adder2;
            NumberAdder _sub  = adder1 - adder2;
            NumberAdder _mult = adder1 * adder2;
            NumberAdder _div  = adder1 / adder2;

            Console.WriteLine("sum = {0}", _add.ToString());
            Console.WriteLine("sub = {0}", _sub.ToString());
            Console.WriteLine("mult = {0}", _mult.ToString());
            Console.WriteLine("div = {0}", _div.ToString());
        }