namespace 移动存储设备03 { public abstract class Yidong { public abstract void Write(); public abstract void Reade(); } }
namespace 移动存储设备03 { //Mp3类 class Mp3:Yidong { public override void Write() { Console.WriteLine("Mp3正在写入中..."); } public override void Reade() { Console.WriteLine("Mp3正在读取中..."); } } }
namespace 移动存储设备03 { //电脑类 class Computer { public Yidong yd { get; set; } public void Write() { yd.Write(); } public void Reade() { yd.Reade(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 移动存储设备03 { class Program { static void Main(string[] args) { Computer com = new Computer(); com.yd = new Upan();//Yidong yd = new Upan com.Write(); com.Reade(); Console.ReadKey(); } } }
时间: 2024-10-14 19:18:35