Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A {
- virtual public void foo () {
- Console.WriteLine("A:foo()");
- }
- }
- class B : A {
- override public void foo() {
- base.foo();
- Console.WriteLine("B:foo()");
- }
- }
- class Program {
- static void Work (A a) {
- Console.WriteLine("working...");
- a.foo();
- }
- static void Main(string[] args) {
- A a = new A();
- A b = new B();
- Work(a);
- Work(b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment