In C#, virtual methods support polymorphism, by using a combination of the virtual and override keywords. With the virtual keyword on the base class method and the override keyword on the method in the derived class, both methods are said to be virtual.

Methods that don't have either the virtual or override keywords, or that have the new keyword, are said to be non-virtual.

When a virtual method is invoked on an object, the run-time type of the object is used to determine which implementation of the method to use.

When a non-virtual method is invoked on an object, the compile-time type of the object is used to determine which implementation of the method to use.

原文地址:#349 - The Difference Between Virtual and Non-Virtual Methods

【转载】#349 - The Difference Between Virtual and Non-Virtual Methods的更多相关文章

  1. ASP.NET :Virtual Application vs Virtual Directory

    原文地址:http://blogs.msdn.com/b/wenlong/archive/2006/11/22/virtual-application-vs-virtual-directory.asp ...

  2. c++ virtual 和 pure virtual的区别

    参考资料: http://stackoverflow.com/questions/1306778/c-virtual-pure-virtual-explained 验证代码: #include < ...

  3. 析构函数virtual与非virtual区别 [转]

    作为通常的原则,如果一个类定义了虚函数,那么它的析构函数就应当是virtual的.因为定义了虚函数则隐含着:这个类会被继承,并且会通过基类的指针指向子类对象,从而得到多态性.   这个类可能会被继承, ...

  4. pure virtual、impure virtual、non-virtual函数的接口继承和实现继承

    1.abstract class 拥有pure virtual函数的class是abstract class. 不能创建abstract class的实体. 2.pure virtual 函数 他们必 ...

  5. [New Portal]Windows Azure Virtual Machine (17) Virtual Machine成本分析

    <Windows Azure Platform 系列文章目录> 在Windows Azure VM里,计费模式是和以下几个因素有关: 成本1: VM Type and VM Size 具体 ...

  6. What is the difference between concurrency, parallelism and asynchronous methods?

    Ref: http://stackoverflow.com/questions/4844637/what-is-the-difference-between-concurrency-paralleli ...

  7. Genymotion模拟器无法开启的解决方法——Unable to start the virtual device,The virtual device got no IP address

    前言 最近重装了电脑的系统,由win7换成了win8.1.android开发环境也重新配置了一遍.其他的都还好,就是genymotion模拟器一直开启失败. 自己尝试了很多方法,比如卸载重装软件,重新 ...

  8. C#中Abstract和Virtual[转载]

    原文:http://www.cnblogs.com/blsong/archive/2010/08/12/1798064.html 在C#的学习中,容易混淆virtual方法和abstract方法的使用 ...

  9. C#中Abstract和Virtual(转载)

    在C#的学习中,容易混淆virtual方法和abstract方法的使用,现在来讨论一下二者的区别.二者都牵涉到在派生类中与override的配合使用. 一.Virtual方法(虚方法) virtual ...

随机推荐

  1. python 文件与异常

    ####文件### r: -只能读 不能写 -读取文件不存在,是会报错 r+: - 可以执行读写操作; - 文件不存在, 报错: w: -只能写,不能读 -会清空文件内容 -文件不存在,会新建文件 w ...

  2. (转)如何使用caffe的MATLAB接口

    编译MatCaffe 转自: http://blog.csdn.net/ws_20100/article/details/50525879 使用如下命令编译MatCaffe make all matc ...

  3. .NET Core单元测试覆盖率统计coverlet配置和使用

    https://segmentfault.com/a/1190000017569492 需要使用: 使用 Moq 测试.NET Core 应用    https://www.cnblogs.com/c ...

  4. 【ACM】阶乘因式分解(二)

    阶乘因式分解(二) 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 给定两个数n,m,其中m是一个素数. 将n(0<=n<=2^31)的阶乘分解质因数,求 ...

  5. python--upload file into HDFS 加载文件到HDFS

    模拟:https://creativedata.atlassian.net/wiki/spaces/SAP/pages/61177860/Python+-+Read+Write+files+from+ ...

  6. Java程序员进阶架构师推荐阅读书籍

    [IT168 技术]作为Java程序员来说,最痛苦的事情莫过于可以选择的范围太广,可以读的书太多,往往容易无所适从.我想就我自己读过的技术书籍中挑选出来一些,按照学习的先后顺序,推荐给大家,特别是那些 ...

  7. Linux IPC 共享内存

    共享内存 共享内存(shared memory)是最简单的Linux进程间通信方式之一. 使用共享内存,不同进程可以对同一块内存进行读写. 由于所有进程对共享内存的访问就和访问自己的内存空间一样,而不 ...

  8. VBS 学习

    VBS其他功能 获取系统用户名 DimWshNetwork Set WshNetwork =CreateObject("WScript.Network") strTaccount ...

  9. SQL事务的四种隔离级别

    1未提交读(Read uncommitted):完全不锁表,所以会出现脏数据.2提交读(Read committed):1.事务1中update才锁表,可以select到最新数据. 事务2select ...

  10. Boxes in a Line UVA - 12657 (双向链表)

    题目链接:https://vjudge.net/problem/UVA-12657 题目大意:输入n,m  代表有n个盒子 每个盒子最开始按1~n排成一行  m个操作, 1 x y  :把盒子x放到y ...