C# 抽象类 abstract

抽象类和重写

using Mysqlx.Notice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Timers;

namespace ClassAndIn
{
    internal class Program
    {
        
        static void Main(string[] args)
        {
            Car car = new MiCar();
            car.Run();
        }
    }

    // 抽象类
    abstract class Car
    {   
        // 抽象方法
        public abstract void Run();
    }

    class MiCar : Car
    {
        public override void Run()
        {
            //throw new NotImplementedException();
            Console.WriteLine("speeding is fast ...");
        }
    }

}

 

posted @ 2025-06-13 14:37  市丸银  阅读(5)  评论(0)    收藏  举报