Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    Classes for exercise.Lecture 7 - slide 40 : 40
Program 3
using System;

public class A {
 public int v = 1;
 public virtual int Op1(){return v;}
}

public class B: A{
 public new int v = 2;
 public override int Op1(){return v;}
 public int Op2(){return base.v;}
}

public class Client{

  public static void Main (){
    A a = new B();
    Console.WriteLine("{0}", a.v);
    Console.WriteLine("{0}", a.Op1());

    B b = new B();
    Console.WriteLine("{0}", b.v);
    Console.WriteLine("{0}", b.Op2());
  }

}