public static void PrintAll(this PrintApp.PhotoPrinter printer, params PrintApp.Photo[] photoArr) { for (int i = 0; i < photoArr.Length; i++) { printer.Print(photoArr[i]); } }
static void Main(string[] args) { Printer printer = new Printer(); Printer colPrinter = new ColourPrinter(); Printer photoPrinter = new PhotoPrinter(); // virtual methods are called printer.Print("message"); colPrinter.Print("message"); photoPrinter.Print("message"); // specialised methods (colPrinter as ColourPrinter).Print("message", ConsoleColor.Blue); (photoPrinter as PhotoPrinter).Print(new Photo()); Console.ReadKey(); }