// TODO: Add Operator to combine Cylinders public static Cylinder operator +(Cylinder leftSide, Cylinder rightSide) { // We cannot combine cylinders with different radius if (leftSide.Radius != rightSide.Radius) throw new NotSupportedException("Cannot add two cylinders with different radius values"); Cylinder result = new Cylinder(leftSide.Radius, leftSide.Height + rightSide.Height); return result; }
//Instance (non-static) methods for my Program private void Display(Cylinder data) { Console.WriteLine("The {0}x{1} cylinder has a volume of {2}.", data.Radius, data.Height, data.Volume); }