Console.WriteLine("Rendering...");
}
}
Now, when we make use of the SuperShape, we are able to invoke each method at the object
level (as they are all public) as well as extract out a reference to each supported interface explicitly
via casting:
static void Main(string[] args)
{
Console.WriteLine("***** The SuperShape *****");
// Call from object level.
SuperShape myShape = new SuperShape();
myShape.Draw();
// Get IPrintable explicitly.
// (and IDrawable implicitly!)
IPrintable iPrint;
iPrint = (IPrintable)myShape;
iPrint.Draw();
iPrint.Print();
Console.ReadLine();
}
Do'stlaringiz bilan baham: