Exemple #1
0
 public static void PrintAll(this PrintApp.Printer printer, params string[] msgArr)
 {
     for (int i = 0; i < msgArr.Length; i++)
     {
         printer.Print(msgArr[i]);
     }
 }
Exemple #2
0
        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();
        }