国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 辰溪县| 信宜市| 常熟市| 西平县| 利辛县| 军事| 白沙| 平乡县| 普陀区| 防城港市| 兴安盟| 关岭| 徐闻县| 乡宁县| 岑溪市| 镶黄旗| 武威市| 东台市| 新民市| 沂源县| 如东县| 湖北省| 永顺县| 开化县| 辰溪县| 通州市| 尉犁县| 涞源县| 铜山县| 五常市| 万安县| 龙口市| 平顶山市| 大渡口区| 历史| 桃园县| 繁峙县| 安庆市| 鸡泽县| 邢台县| 双鸭山市|