zoukankan      html  css  js  c++  java
  • C#扩充类

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace 课本习题
    {
        public class Animal
        {
            public Animal()
            {
                Console.WriteLine("基类构造函数:Hello,Animal");
            }
            public void Eat()
            {
                Console .WriteLine("扩充类方法:Eating");
            }
        }
        public class Cat:Animal
        {
            public Cat()
            {
                Console.WriteLine("扩充类构造函数:Hello,Cat");
            }
            public void Walk()
            {
                Console .WriteLine("扩充类方法:Walking");
            }
        }
        class Program
        {
            static void Main(string[] args)
            {
                Cat cat=new Cat ();
                cat.Eat();
                cat.Walk();
                Console .ReadLine();
            }
        }
    }
    


  • 相关阅读:
    20210123
    20210122
    20210121
    20210120
    2020119
    20210118
    20210117
    20210116
    例2-8
    例2-6
  • 原文地址:https://www.cnblogs.com/alfredsun/p/4467240.html
Copyright © 2011-2022 走看看