using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { //父类 BaseClass Basefun = new BaseClass(); Basefun.Basefun(); //扩展父类方法,注意实例的对象为子类 BaseClass Subfun = new SubClass(); Subfun.Basefun(); Console.ReadKey(); } class BaseClass { public virtual void Basefun() { Console.WriteLine("父类方法"); } } class SubClass:BaseClass { public override void Basefun() { Console.WriteLine("子类方法"); } } }}