Exemplo n.º 1
0
 public void LSPResponsibility()
 {
     {
         Chinese people = new Chinese();
         people.Traditional();
         DoChinese(people);
     }
     {
         Chinese people = new HuBei();
         people.Traditional();
         DoChinese(people);//people 的实例方法是Chinese
     }
     {
         var people = new HuBei();//执行左边的类的属性方法
         people.Traditional();
         DoChinese(people);
         people.SayHi();//people 的实例方法是Hubei
     }
 }
Exemplo n.º 2
0
 private static void DoHuBei(HuBei people)
 {
     Console.WriteLine($"{people.Id},{people.Name}{people.KuaiZi}");
     people.SayHi();
 }