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

推荐订阅源

Project Zero
Project Zero
月光博客
月光博客
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
O
OpenAI News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Know Your Adversary
Know Your Adversary
Last Week in AI
Last Week in AI
S
Securelist
Engineering at Meta
Engineering at Meta
博客园 - 司徒正美
P
Privacy & Cybersecurity Law Blog
T
Tailwind CSS Blog
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
Scott Helme
Scott Helme
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hugging Face - Blog
Hugging Face - Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
SecWiki News
SecWiki News
宝玉的分享
宝玉的分享
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
Lohrmann on Cybersecurity
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
I
InfoQ
S
Security @ Cisco Blogs
Webroot Blog
Webroot Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
人人都是产品经理
人人都是产品经理
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
B
Blog RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - 言午

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();
                }
            }
                        
        }
    }