Что означает строка кода "Protected ConsoleColor color" - C#
Формулировка задачи:
Листинг программы
- using System;
- namespace Lessons_3
- {
- class Program
- {
- static void Main()
- {
- ColorPrinter print = new ColorPrinter(ConsoleColor.Yellow);
- print.Print("Hello");
- Printer printUp = print;
- printUp.Print("Hello");
- ColorPrinter print1 = new ColorPrinter(ConsoleColor.Red);
- print1.Print("Hello");
- // Delay.
- Console.ReadKey();
- }
- }
- class Printer
- {
- protected ConsoleColor color;
- public Printer(ConsoleColor color)
- {
- this.color = color;
- }
- //Console.ForegroundColor = ConsoleColor.White;
- public virtual void Print(string value)
- {
- Console.ForegroundColor = color;
- Console.WriteLine(value);
- Console.ForegroundColor = ConsoleColor.Gray;
- }
- }
- class ColorPrinter : Printer
- {
- public ColorPrinter(ConsoleColor color)
- : base(color)
- {
- }
- }
- }
Решение задачи: «Что означает строка кода "Protected ConsoleColor color"»
textual
Листинг программы
- // Create a new derived type.
- Giraffe g = new Giraffe();
- // Implicit conversion to base type is safe.
- [B][U]Animal a = g;[/U][/B]
- // Explicit conversion is required to cast back
- // to derived type. Note: This will compile but will
- // throw an exception at run time if the right-side
- // object is not in fact a Giraffe.
- Giraffe g2 = (Giraffe) a;
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д