zoukankan      html  css  js  c++  java
  • C#多态(二)

    View Code
     1  public class studyMutils
     2  {
     3      public static void Main()
     4      {
     5          People p = new Student();
     6          p.Watch();
     7          p.Read();
     8      }
     9  }
    10  public class People
    11  {
    12     
    13      public void Say()
    14     {
    15       Console.WriteLine("今天好累啊");     
    16      }
    17      public virtual void Watch()
    18     {
    19       Console.WriteLine("我喜欢看动画片");     
    20      }
    21       public virtual void Read()
    22     {
    23          
    24       Console.WriteLine("我喜欢读读者");
    25      }
    26  }
    27  public class Teacher : People
    28  {
    29      public void Run()
    30     {
    31           Console.WriteLine("hello");
    32      }
    33       public override void Watch()
    34     {
    35       Console.WriteLine("我喜欢看武侠片");     
    36      }
    37      public override void Read()
    38     {
    39          
    40       Console.WriteLine("我喜欢读哲学");
    41      }
    42  }
    43  public class Student : Teacher
    44  {
    45      public  override void Watch()
    46     {
    47       Console.WriteLine("我喜欢看警匪片");
    48      }
    49     
    50  }
  • 相关阅读:
    20180530
    vue路由配置出错,导致页面跳转会有闪屏问题
    20180528
    vuecli+ivew项目搭建
    centos6安装mysql
    华为云服务ESC
    centos6安装nginx
    国产操作系统aarch64编译filebeat
    Python常见问题
    Git
  • 原文地址:https://www.cnblogs.com/QLJ1314/p/2622907.html
Copyright © 2011-2022 走看看