1、方法多态
2、属性多态
1 public class Contact
2 {
3 public virtual string Email { get; set; }
4 }
5
6 public class Customer : Contact
7 {
8 public override string Email
9 {
10 get
11 {
12 return base.Email;
13 }
14 set
15 {
16 base.Email = value;
17 }
18 }
19 }
3、索引器多态
1 public class SiteList
2 {
3
4 protected string[] sites = new string[5];
5
6 public virtual string this[int index]
7 {
8 get
9 {
10 return sites[index];
11 }
12 set
13 {
14 sites[index] = value;
15 }
16 }
17 }
18
19 public class FinancialSiteList : SiteList
20 {
21 public override string this[int index]
22 {
23 get
24 {
25 if (index > sites.Length)
26 {
27 return (string)null;
28 }
29 return base[index];
30 }
31 set
32 {
33 base[index] = value;
34 }
35 }
36 }