国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

c#.net中類的覆寫(OverRide)

2024-07-10 13:07:19
字體:
供稿:網(wǎng)友

c#.net中類的覆寫(override)

 

public class mybase
...{
   public virtual string meth1()
   ...{
      return "mybase-meth1";
   }
   public virtual string meth2()
   ...{
      return "mybase-meth2";
   }
   public virtual string meth3()
   ...{
      return "mybase-meth3";
   }
}

class myderived : mybase
...{
   // overrides the virtual method meth1 using the override keyword:
   public override string meth1()
   ...{
      return "myderived-meth1";
   }
   // explicitly hide the virtual method meth2 using the new
   // keyword:
   public new string meth2()
   ...{
      return "myderived-meth2";
   }
   // because no keyword is specified in the following declaration
   // a warning will be issued to alert the programmer that
   // the method hides the inherited member mybase.meth3():
   public string meth3()
   ...{
      return "myderived-meth3";
   }

   public static void main()
   ...{
      myderived md = new myderived();
      mybase mb = (mybase) md;

      system.console.writeline(mb.meth1());
      system.console.writeline(mb.meth2());
      system.console.writeline(mb.meth3());
   }
}

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 洪洞县| 绥江县| 房产| 林周县| 孙吴县| 顺平县| 乐山市| 虹口区| 潜江市| 平武县| 徐闻县| 湖北省| 白城市| 永平县| 宣城市| 哈巴河县| 壤塘县| 龙胜| 无极县| 都江堰市| 九龙坡区| 宁陵县| 博野县| 德钦县| 广东省| 寿宁县| 太谷县| 贵德县| 青海省| 武山县| 新野县| 体育| 东乡县| 达孜县| 定兴县| 肇庆市| 绥化市| 克拉玛依市| 三原县| 弋阳县| 叙永县|