• AutoCAD.Net/C#.Net QQ群:193522571 虚拟方法的使用


    shell类中有一个虚方法;

    而其子类Cylinder、Head及其子类中去实现此虚方法;

    这样,在其它类如Main类中可以通过shell及其子类的实例来调用此虚方法;

    如:new 一个HeadEllipse  EH

    用方法Draw(EH)来实现;

      public class Main
      {
      
    public void Draw(Shell shell) { shell.Draw(); } } public class Shell : Part { public virtual ObjectId Draw() { return ObjectId.Null; } } public class Cylinder : Shell { public override ObjectId Draw() { int identify = this.GetCurrentPartIdentity<Cylinder>() + 1; ObjectId id = Draw(identify); this.SetCurrentPartIdentity<Cylinder>(identify); return id; } } public class Head : Shell { } public class HeadEllipse : Head { public override ObjectId Draw() { int identify = this.GetCurrentPartIdentity<HeadEllipse>() + 1; ObjectId id = Draw(identify); this.SetCurrentPartIdentity<HeadEllipse>(identify); return id; } } public class HeadDished : Head { public override ObjectId Draw() { int identify = this.GetCurrentPartIdentity<HeadDished>() + 1; ObjectId id = Draw(identify); this.SetCurrentPartIdentity<HeadDished>(identify); return id; } }
  • 相关阅读:
    点对点PSCV
    开机启动文件夹
    SpringBoot占用端口
    停止8080端口
    java JDK下载与安装教程
    JRebel热部署
    取消ctrl+alt+箭头 旋转
    空指针调试
    xdebug 断点调试,时间过长会出现超时如何解决
    vue 无法加载文件 CProgram Filesnodejsnpm.ps1,因为在此系统上禁止运行脚本
  • 原文地址:https://www.cnblogs.com/swtool/p/14220352.html
Copyright © 2020-2023  润新知