Example #1
0
 private static void DrawRectangle()
 {
     Console.WriteLine("Object of type rectangle stored in a variable of type rectangle\n");
     Rectangle rectangle = new Rectangle();
     rectangle.Draw();
     Console.WriteLine("*********************************\n");
 }
Example #2
0
 private static void AssignDifferentTypesToSameInstanceVariable()
 {
     Console.WriteLine("Instance variable holds a type of circle, and then a type of rectangle. The draw methods change\n");
     IShape shape = new Circle();
     Console.WriteLine("The object variable is of type IShape,\nand is holding an instance of a Circle.\n");
     shape.Draw();
     Console.WriteLine("The object variable is of type IShape,\nbut is now holding an instance of a Rectangle.\n");
     shape = new Rectangle();
     shape.Draw();
 }