Example #1
0
 // 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;
 }
Example #2
0
 //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);
 }