static void Main() { IIndex <Rectangle> rectangles = RectangleCollection.GetRectangles(); IIndex <Shape> shapes = rectangles; for (int i = 0; i < shapes.Count; i++) { Console.WriteLine(shapes[i]); } IDisplay <Shape> shapeDisplay = new ShapeDisplay(); IDisplay <Rectangle> rectangleDisplay = shapeDisplay; rectangleDisplay.Show(rectangles[0]); }
public static RectangleCollection GetRectangles() => coll ?? (coll = new RectangleCollection());
public static RectangleCollection GetRectangles() { return(coll ?? (coll = new RectangleCollection())); }