public static void PrintAll(this PrintApp.ColourPrinter printer, params Tuple <string, ConsoleColor>[] msgColArr) { for (int i = 0; i < msgColArr.Length; i++) { printer.Print(msgColArr[i].Item1, msgColArr[i].Item2); } }
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(); }