public static void ExtendPrint(this ColorPrinter printer, string[] text, ConsoleColor color) { foreach (var line in text) { printer.Print(line, color); } }
static void Main(string[] args) { ColorPrinter colorPrinter = new ColorPrinter(); ColorPrinter[] colorArray = { new ColorPrinter(), new ColorPrinter(), new ColorPrinter() }; //colorPrinter.PrintArray(); colorArray.Print("Hello", ConsoleColor.Blue); PhotoPrinter[] photoPrinter = { new PhotoPrinter(), new PhotoPrinter(), new PhotoPrinter() }; photoPrinter.Print(new Photo(), new Photo(), new Photo(), new Photo()); Printer printer = new Printer(); string[] str = { "1", "2", "3" }; printer.PrintArray(str); Console.ReadKey(); }
static void Main(string[] args) { var colorPrinter = new ColorPrinter(); colorPrinter.ExtendPrint(new string[] { "message1", "message2" }, ConsoleColor.Cyan); var photoPrinter = new PhotoPrinter(); photoPrinter.ExtendPrint(new Photo[] { new Photo(), new Photo() }); photoPrinter.ExtendPrint(new string[] { "text1", "text2", "text3" }); Console.ReadKey(); }
static void Main(string[] args) { Printer myPrinter = new Printer(); myPrinter.PrinterExtention(); ColorPrinter colorPrinter = new ColorPrinter(); colorPrinter.ColorPrinterExtention(ConsoleColor.Cyan); Photo myPhoto = new Photo("^-^"); PhotoPrinter photoPrinter = new PhotoPrinter(); photoPrinter.PhotoPrinterExtention(myPhoto); Console.ReadKey(); }
public static void ColorPrinterExtention(this ColorPrinter colorPrinter, ConsoleColor color) { Console.ForegroundColor = color; colorPrinter.Print("Printed from Color printer extention! Extends the "); Console.ResetColor(); }