Recall that polymorphism is one of the three core principles of object-oriented programming.

Polymorphism is the idea that the same code can act differently, depending on the underlying type of the object being acted upon. The type of the object is determined at run-time, rather than at compile-time.

In C#, you can use a variable declared as a base type to refer to instances of one or more derived types. Polymorphism allows you to call a method that exist in the base type but whose implementation exists in the derived types. The appropriate method in the derived type will be called, based on the type of the object.

 Dog d;

 d = new Terrier("Jack", );
d.Bark(); // Terrier.Bark is called d = new Shepherd("kirby", );
d.Bark(); // Shepherd.Bark is called

 原文地址:#346 - Polymorphism

【转载】#346 - Polymorphism的更多相关文章

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

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

  2. [转载] Android逃逸技术汇编

    本文转载自: http://blogs.360.cn/360mobile/2016/10/24/android_escape/ 摘    要 传统逃逸技术涉及网络攻防和病毒分析两大领域,网络攻防领域涉 ...

  3. iOS开发中遇到的一些问题及解决方案【转载】

    iOS开发中遇到的一些问题及解决方案[转载] 2015-12-29 [385][scrollView不接受点击事件,是因为事件传递失败] // //  MyScrollView.m //  Creat ...

  4. 【转载】Stack Overflow: The Architecture - 2016 Edition

    转载:http://www.infoq.com/cn/news/2016/03/Stack-Overflow-architecture-insi?utm_source=tuicool&utm_ ...

  5. JVM学习(1)——通过实例总结Java虚拟机的运行机制-转载http://www.cnblogs.com/kubixuesheng/p/5199200.html

    JVM系类的文章全部转载自:http://www.cnblogs.com/kubixuesheng/p/5199200.html 特别在此声明.那位博主写的真的很好 ,感谢!! 俗话说,自己写的代码, ...

  6. <转载> 22种代码味道(Martin Fowler与Kent Beck) http://blog.csdn.net/lovelion/article/details/9301691

    Martin Fowler在Refactoring: Improving the Design of Existing Code(中译名:<重构——改善既有代码的设计>)一书中与Kent ...

  7. 如何分析解决Android ANR(转载)

    转载自:http://blog.csdn.net/dadoneo/article/details/8270107 一:什么是ANR ANR:Application Not Responding,即应用 ...

  8. c++ 宏多态 动态多态和静态多态(转载)

    转载出处:通道 多态(polymorphism)一词最初来源于希腊语polumorphos,含义是具有多种形式或形态的情形.在程序设计领域,一个广泛认可的定义是“一种将不同的特殊行为和单个泛化记号相关 ...

  9. Java基础-面向对象第三大特性之多态(polymorphism )

    Java基础-面向对象第三大特性之多态(polymorphism) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.多态概述 多态是继封装,继承之后,面向对象的第三大特性,多态的 ...

随机推荐

  1. Qt中的标准对话框

    1. Qt为开发者提供了一些可复用的对话框类型,如QMessageBox,QFileDialog,QPrintDialog, QColorDialog, QInputDialog, QProgress ...

  2. hive 全表全字段对比

    select * from ( select max(t1.source) as source ,t1.c1 ,t1.c2 ,t1.c3 ,count(*) as cnt from ( as sour ...

  3. ssh两台主机建立信任关系

    A主机(10.104.11.107)   B主机(10.104.11.128) A: ssh-keygen -t rsa [root@H0f .ssh]# ssh-keygen -t rsa Gene ...

  4. java——最大堆 MaxHeap

    使用数组来实现最大堆 堆是平衡二叉树 import Date_pacage.Array; public class MaxHeap<E extends Comparable <E>& ...

  5. shematool -initschema -dbtype mysql error org.apache.hadoop.hive.metastore.hivemetaexception:Failed to get schema version

    命令:schematool -initSchema -dbType mysql Fix the issue: edit /etc/mysql/my.cnf change bind-address   ...

  6. python安装包的时候报错

    python安装包的时候报错 今天兴致勃勃的安装了一个paramiko包,过程很顺利,但是到结尾的时候报错,这就让人不爽了. 所以呢,需要安装一个名为python-dev的软件包. 该软件包包括头文件 ...

  7. ES6结构赋值

    解构赋值 从ES6开始,JavaScript引入了解构赋值,可以同时对一组变量进行赋值. 什么是解构赋值?我们先看看传统的做法,如何把一个数组的元素分别赋值给几个变量: var array = ['h ...

  8. ES6多行字符串+模板字符串

    多行字符串 最新的ES6标准新增了一种多行字符串的表示方法,用反引号 ` ... ` 表示: 'use strict'; // 如果浏览器支持模板字符串,将会替换字符串内部的变量: var name ...

  9. Mac使用zsh导致maven命令无效的解决方案

    第一步: vim ~/.zshrc 第二步:在.zshrc末尾加上 source ~/.bash_profile: 保存推出了 第三步 source ~/.bash_profile

  10. leetcode 181 Employees Earning More Than Their Managers 不会分析的数据库复杂度

    https://leetcode.com/problems/employees-earning-more-than-their-managers/description/ 老师上课没分析这些的复杂度, ...