1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace ConsoleApplication14
6 {
7 class Program
8 {
9 static void Main(string[] args)
10 {
11
12 B b = new B();
13 A A = b;
14 A.show();
15 b.show();
16 // 输出
17
18 //B...
19
20 //A...
21
22 //B...
23
24 //A...
25
26
27
28 Console.ReadKey();
29 }
30 }
31
32
33 class A {
34
35 public virtual void show() {
36
37 Console.WriteLine("A...
");
38
39 }
40
41 }
42 class B:A
43 {
44
45 public override void show()
46 {
47
48 Console.WriteLine("B...
");
49 base.show();
50
51 }
52
53 }
54 }
base 常用于在派生类初始化时和基类进行通讯