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

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - 言午

Nopcommerce 二次开发2 Admin Nopcommerce 二次开发1 基础 Nopcommerce 二次开发2 WEB Nopcommerce 二次开发0 sqlce中不支持sp_rename修改表名 C#读取Excel遇到无法读取的解决方法 狼奔代码生成器 银行账户类 累 抽象类 抽象方法 Message 类的继承 多态(虚方法) 事件event 委托 代理 索引! 第五周作业 第四周作业 考试! 线程安全 二 线程安全 一
interface
言午 · 2012-04-18 · via 博客园 - 言午

interface Ishirou
    {       
        void Hunt();
    }
    interface Ishicao
    {
        void EatGrass();
    }
    abstract class Animal
    {
        public abstract void Eat();     
    }
    class Cat : Animal,Ishirou
    {
        public override void Eat() { Console.WriteLine("猫吃鱼"); }  
        public void Hunt()
        {
            Console.WriteLine("猫捉老鼠");           
        }
    }
    class Tiger : Animal, Ishirou
    {
        public override void Eat() { Console.WriteLine("老虎也吃鱼"); }
        public void Hunt()
        {
            Console.WriteLine("老虎捉羊");
        }
    }
    class Sheep : Animal, Ishicao
    {
        public override void Eat() { Console.WriteLine("羊吃草"); }  
        public void EatGrass()
        {          
        }
    }

    class Program
    {       
        static void Main(string[] args)
        {  
            List<Animal> animals = new List<Animal>();
            Animal a1 = new Cat();
            animals.Add(a1);
            Animal a2 = new Sheep();
            animals.Add(a2);
            Animal a3 = new Sheep();
            animals.Add(a3);
            Animal a4 = new Tiger();
            animals.Add(a4);          

            foreach (Animal a in animals)
            {
                if (a is Ishirou)
                {
                    Ishirou irou = (Ishirou)a;                    
                    irou.Hunt();
                }
            }
                        
        }
    }