惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Schneier on Security
Schneier on Security
N
Netflix TechBlog - Medium
IT之家
IT之家
MongoDB | Blog
MongoDB | Blog
博客园_首页
S
SegmentFault 最新的问题
H
Help Net Security
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
T
The Blog of Author Tim Ferriss
量子位
GbyAI
GbyAI
M
MIT News - Artificial intelligence
Recorded Future
Recorded Future
P
Privacy & Cybersecurity Law Blog
B
Blog
月光博客
月光博客
博客园 - 聂微东
Vercel News
Vercel News
罗磊的独立博客
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
A
Arctic Wolf
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
L
Lohrmann on Cybersecurity
I
Intezer
小众软件
小众软件
T
The Exploit Database - CXSecurity.com
Jina AI
Jina AI
C
Check Point Blog
AWS News Blog
AWS News Blog
C
Cisco Blogs
Martin Fowler
Martin Fowler
The Last Watchdog
The Last Watchdog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
宝玉的分享
宝玉的分享
S
Security Affairs
大猫的无限游戏
大猫的无限游戏
N
News and Events Feed by Topic
雷峰网
雷峰网
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hacker News: Front Page
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Full Disclosure
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog

博客园 - 左少白

oracle 找回DROP掉的表 求解,工作流点通过时,弹出窗口让用户录入审核意见 oracle 游标 sqlserver 按五分钟分组 c# 继承 查询行转列 SqlParameter序列化的问题 oracle oracle trunc (date,dd )函数 oracle 游标 对象集合转换为datatable 用C# 正则 提取HTML标签中的值? oracle decode 与 case when ,空的处理 oracle select for update sql1 同期进度,完成率 Oracle Index 相關知識 玩转DevExpress.XtraGrid.view.gridview oracle索引 在Oracle中进行大小写不敏感的查询2
c# 多态
左少白 · 2012-04-18 · via 博客园 - 左少白

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleExample

{

    class 哥

    {

        public virtual void draw()

        {

            Console.WriteLine("哥来做事,你们可以偷偷乐了");

        }

        public void ff()

        { 

            Console.WriteLine("哥的FF方法");

        }

    }

    class 小弟 : 哥

    {

        public override void draw()

        {

            Console.WriteLine("小弟不用哥的,小弟要单干");

            //base.draw();

        }

        public new void ff()

        {

            Console.WriteLine("小第的FF方法");

        }

    }

    class 小妹 : 哥

    {

        public new void ff()

        {

            Console.WriteLine("小妹的FF方法");

        }

    }

}

 public static void Main()

  { 

           哥[] father = new 哥[3];

            father[0] = new 哥();

            father[1] = new 小弟();

            father[2] = new 小妹();

            foreach (哥 t in father)

            {

                t.draw();    //调用实际的重写对象的方法(子类里面,如果override 了draw方法,调用它,没有就调用父类的draw方法)           

            }

            小弟 tt = new 小弟();

            tt.draw();      //调用实际的重写对象的方法(子类里面,如果override 了draw方法,调用它,没有就调用父类的draw方法)

            tt.ff();        //调用本类的方法(小第里面的方法)

            哥 bb = tt;

            bb.draw();      //调用实际的重写对象的方法(子类里面,如果override 了draw方法,调用它,没有就调用父类的draw方法)

            bb.ff();        //调用本类的方法 (哥里的方法)

            哥 cc = new 小妹();

            cc.draw();      //调用实际的重写对象的方法(子类里面,如果override 了draw方法,调用它,没有就调用父类的draw方法)

            cc.ff();        //本类的方法(哥里的方法,是非虚方法) 

            哥 gg = new 小弟();

            ((小弟)gg).draw();//调用实际的重写对象的方法(类小弟里面,如果override 了draw方法,调用它,没有就调用父类的draw方法)

            ((小弟)gg).ff();  //类小弟的方法(base里的方法)

 }

结果如下: