Advertisement
renurtt

Untitled

Aug 25th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Application
  4. {
  5.     public interface I
  6.     {
  7.         void Go();
  8.     }
  9.  
  10.     public class A : I
  11.     {
  12.         public void Go()
  13.         {
  14.             Console.WriteLine("A.Go()");
  15.         }
  16.     }
  17.  
  18.     public class B : A
  19.     {
  20.        
  21.     }
  22.  
  23.     public class C : B
  24.     {
  25.         public new void Go()
  26.         {
  27.             Console.WriteLine("C.Go()");
  28.         }
  29.     }
  30.    
  31.     class MainClass
  32.     {
  33.         public static void Main(string[] args)
  34.         {
  35.             B b1 = new B();
  36.             C c1 = new C();
  37.             B b2 = c1;
  38.             b1.Go();
  39.             c1.Go();
  40.             b2.Go();
  41.             ((I) b2).Go();
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement