zoukankan      html  css  js  c++  java
  • C#学习抽象类和方法

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication2
    {
        class Program
        {
            abstract public class MotorVehicle
            {
                public string make;
                public string model;

                public MotorVehicle(string make, string model)
                {
                    this.make = make;
                    this.model = model;
                }
                abstract public void Accelerate();
            }

            public class Car : MotorVehicle
            {
                public Car(string make, string model)
                    : base(make, model)
                {
                    //do nothing
                }

                public override void Accelerate()
                {
                    Console.WriteLine("In Car Accelerate() method");
                    Console.WriteLine(model + " accelerating");
                }
            }

            static void Main(string[] args)
            {
                Console.WriteLine("Creating a Car object");
                Car myCar = new Car("Toyata","MR2");

                Console.WriteLine("Calling myCar.Accelerate()");
                myCar.Accelerate();
                string i = System.Console.ReadLine();
            }
        }
    }

  • 相关阅读:
    ESP8266-12F引脚接法
    esp8266物联网开发六:让ESP32-CAM五彩斑斓
    esp8266物联网开发五:SSL保驾护航
    esp8266物联网开发四:MQTT再论部控
    esp8266物联网开发三:MQTT初窥貌容
    esp8266物联网开发二:Arduino名门正派
    esp8266物联网开发一:MicroPython初战江湖
    一些错误记录
    jimdb压测踩坑记
    Caffeine批量加载浅析
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2035644.html
Copyright © 2011-2022 走看看