Guest User

Untitled

a guest
Aug 26th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1.     class A {
  2.         virtual public void foo () {
  3.             Console.WriteLine("A:foo()");
  4.         }
  5.     }
  6.  
  7.     class B : A {
  8.         override  public void foo() {
  9.             base.foo();
  10.             Console.WriteLine("B:foo()");
  11.         }
  12.     }
  13.  
  14.     class Program {
  15.         static void Work (A a) {
  16.             Console.WriteLine("working...");
  17.             a.foo();
  18.         }
  19.  
  20.         static void Main(string[] args) {
  21.             A a = new A();
  22.             A b = new B();
  23.             Work(a);
  24.             Work(b);
  25.         }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment