zoukankan      html  css  js  c++  java
  • 面向对象:接口

    namespace ConsoleApplication4
    {
        class dongwu
        {
            public void youyong()
            {
                Console.WriteLine("She was splendid like our flagship!");
            }
            public void quanji()
            {
                Console.WriteLine("But it's all in the past!");
            }
            public void tiaowu()
            {
                Console.WriteLine("Target Yamato!");
            }
        }
    }
    namespace ConsoleApplication4
    {
        class dog:dongwu,Interface1,Interface2
        {
            void Interface1.changge()
            {
                Console.WriteLine("She never gave up the hope even till the end!");
            }
            void Interface2.changge()
            {
                Console.WriteLine("Only the sea knows!");
            }
        }
    }
    namespace ConsoleApplication4
    {
        class Program
        {
            static void Main(string[] args)
            {
                dog data = new dog();
                Interface1 idata = new dog();//接口不能建立自己的实例,可以通过子类新建自己的实例
    
    
             
                dog data1 = new dog();
                Interface1 idata1 = data1;//接口可以实现基类的类型相互转换
                data1 = (dog)idata1;
    
    
    
                Interface1 idatai = new dog();//显示接口,接口中同名函数区分:子类中“Interface.方法名()”区分
                Interface2 idataii = new dog();
                idatai.changge();//显示接口的方法必须通过接口类型实例调用
                idataii.changge();
    
                idatai.tiaowu();//接口中同名函数不区分方法默认为所有接口中都是同一个方法
                idataii.tiaowu();
    
    
    
                Console.ReadLine();
    
            }
        }
    }
  • 相关阅读:
    人脸识别的一些网站
    41、过滤驱动程序
    13、ActiveX控件
    42、驱动程序调试
    20、宽字符串与字符串间的相互转换
    14、HOOK和数据库访问
    43、Windows驱动程序模型笔记(一)
    7、注册表读写的一个例子
    12、动态链接库,dll
    40、总结IRP,handling IRPs,Part II
  • 原文地址:https://www.cnblogs.com/dlexia/p/4536059.html
Copyright © 2011-2022 走看看