It's possible for a class to implement more than one interface.

For example, a Cow class might implement both the IMoo and the IMakeMilk interfaces. Multiple interfaces are listed after the class declaration, separated by commas.

 public class Cow: IMoo, IMakeMilk
{
public void Moo()
{
// do mooing here
} public double Milk()
{
// do milking here
}
}

You can now use an instance of the Cow class to access members of either interface.

 Cow bossie = new Cow("Bossie", );

 // Call both IMoo and IMakeMilk methods
bossie.Moo(); // IMoo.Moo
double numGallons = bossie.Milk(); // IMakeMilk.Milk

We can also set interface variables of either interface type to an instance of a Cow.

 IMoo mooStuff = bossie;
IMakeMilk milkStuff = bossie; mooStuff.Moo();
numGallons = milkStuff.Milk();

原文地址:#440 - A Class Can Implement More than One Interface

【转载】#440 - A Class Can Implement More than One Interface的更多相关文章

  1. 关于C#你应该知道的2000件事

    原文 关于C#你应该知道的2000件事 下面列出了迄今为止你应该了解的关于C#博客的2000件事的所有帖子. 帖子总数= 1,219 大会 #11 -检查IL使用程序Ildasm.exe d #179 ...

  2. 【转载】Serial NOR Flash and U-Boot

    转载自:http://blackfin.uclinux.org/doku.php?id=bootloaders:u-boot:serial-flash U-Boot supports serial N ...

  3. 让你Android开发更简单

    转载:http://www.jianshu.com/p/22ff8b5fdadc 搭建一个新的Android项目,你会怎么做? 每个人对应用框架的理解不相同,但是最终达到的效果应该是一样: ①降低项目 ...

  4. erl0001-Erlang 设计原则 process port io

    Erlang原理 (转载自ITEYE cryolite博客 ps:精彩)by Robert Virding This is a description of some of the basic pro ...

  5. Spark编程模型及RDD操作

    转载自:http://blog.csdn.net/liuwenbo0920/article/details/45243775 1. Spark中的基本概念 在Spark中,有下面的基本概念.Appli ...

  6. epoll内核源码分析

    转载:https://www.nowcoder.com/discuss/26226?type=0&order=0&pos=27&page=1 /*  *  fs/eventpo ...

  7. Adaptively handling remote atomic execution based upon contention prediction

    In one embodiment, a method includes receiving an instruction for decoding in a processor core and d ...

  8. Java-Class-I:java.util.List

    ylbtech-Java-Class-I:java.util.List 1.返回顶部 1.1.import java.util.ArrayList;import java.util.List; 1.2 ...

  9. Java的集合(一)

    转载:https://blog.csdn.net/hacker_zhidian/article/details/80590428 Java集合概况就三个:List.set和map list(Array ...

随机推荐

  1. 论文阅读 | STDN: Scale-Transferrable Object Detection

    论文地址:http://openaccess.thecvf.com/content_cvpr_2018/papers/Zhou_Scale-Transferrable_Object_Detection ...

  2. How to download Heavy Duty Diagnostic Caterpillar SIS 2018 software

    Maybe you find there are supplied Caterpillar SIS 2018 software free download in search engine, that ...

  3. python_学生信息管理实例

    """提示:代码中的内容均被注释,请参考,切勿照搬""" """注意:代码切勿照搬,错误请留言指出" ...

  4. oracle 集群RAC搭建(四)--grid部署

    安装教程:

  5. nginx 服务器配置文件指令

    localtion 配置        语法结构: location [ =  ~  ~* ^~ ] uri{ ... }        uri 变量是带匹配的请求字符, 可以是不含正则表达的字符串, ...

  6. 利用paramiko的demo_simple.py进行日志记录时遇到的特殊字符

    特殊字符列表: 回车 "\r" "\x13" 响铃 "\x07" 换行 "\n" "\x10" &q ...

  7. Yii 自带的分页实例

    yii自带的分页很好用,简单的几行代码就能把分页搞出来,唯一恼火的是只能写在controller中,所以有时候controller中的方法有点臃肿.废话少说,上代码上图. 一.代码实例: 1.控制器中 ...

  8. Zookeeper概念学习系列之zookeeper是什么?

    1. Zookeeper是Hadoop的分布式协调服务. 2. 分布式应用程序可以基于它,来实现同步服务,配置维护和命名服务等. 3. zookeeper可以保证数据在zookeeper集群之间的数据 ...

  9. 面试题 数据库sql

    一.建表的结构和数据,在sqlserver直接用就行了 USE [test] GO /****** Object: Table [dbo].[TEACHER] Script Date: 05/16/2 ...

  10. link快捷方式

    ln -s 源文件 newfile   -软连接 ln 源文件 newfile  硬链接   源文件删除之后仍然可以使用