Advertisement
ivandrofly

Boxing / Cast, Interfact, Abstract, Concrete

Jan 23rd, 2016
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         interface IText
  12.         {
  13.             string ToText();
  14.         }
  15.         class Subtip : SubtitleFormat, IText
  16.         {
  17.             public int Error { get; set; }
  18.  
  19.             public Subtip(int error)
  20.             {
  21.                 Error = error;
  22.             }
  23.             public string ToText()
  24.             {
  25.                 return $"{Error}, Hello!";
  26.             }
  27.         }
  28.         abstract class SubtitleFormat
  29.         {
  30.             protected int _errorCount = 1;
  31.  
  32.             public int ErrorCount
  33.             {
  34.                 get
  35.                 {
  36.                     return _errorCount;
  37.                 }
  38.             }
  39.         }
  40.         static void Main(string[] args)
  41.         {
  42.             SubtitleFormat sb = new Subtip(10);
  43.             IText sb2 = sb as IText;
  44.  
  45.             Console.WriteLine(sb.ErrorCount);
  46.             Console.WriteLine((sb as Subtip).Error);
  47.             Console.WriteLine(sb2.ToText());
  48.             Console.ReadLine();
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement