Exemplo n.º 1
0
        static void DemoOperatorOverloading()
        {
            Cylinder barrel = new Cylinder(5, 20);
            Console.WriteLine("The volume is " + barrel.Volume + ".");

            Cylinder doubleBarrel = barrel + barrel;
            Console.WriteLine("The volume is " + doubleBarrel.Volume + ".");
        }
Exemplo n.º 2
0
 public static Cylinder operator +(Cylinder leftSide, Cylinder rightSide)
 {
     Cylinder result = new Cylinder(leftSide.Radius, (leftSide.Height + rightSide.Height));
     return result;
 }