![]()
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 namespace suoyinzhishiqi
6 {
7 public class B
8 {
9 public void outstring()
10 {
11 Console.WriteLine("This is the base class!");
12 }
13 }
14 public class A : B
15 {
16
17 }
18 public class C : B
19 {
20 new public void outstring()//利用new隐藏基类成员
21 {
22 Console.WriteLine("deriverd cass C");
23 }
24 }
25 class OvrIndexer
26 {
27
28 static void Main(string[] args)
29 {
30 A a = new A();
31 C c = new C();
32 B b = new B();
33 a.outstring();
34 b.outstring();
35 c.outstring();
36 }
37 }
38 }