https://msdn.microsoft.com/en-us/library/ebca9ah3.aspx

The override modifier is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.

Example

In this example, the Square class must provide an overridden implementation of Area because Area is inherited from the abstract ShapesClass:

abstract class ShapesClass
{
abstract public int Area();
} class Square : ShapesClass
{
int side = ; public Square(int n)
{
side = n;
} /// <summary>
/// Area method is required to avoid a compile-time error.
/// </summary>
/// <returns></returns>
public override int Area()
{
return side*side;
} internal static void Method()
{
Square sq = new Square();
Console.WriteLine("Area of the square = {0}", sq.Area());
} interface I
{
void M();
} abstract class C : I
{
public abstract void M();
} }

An override method provides a new implementation of a member that is inherited from a base class.

The method that is overridden by an override declaration is known as the overridden base method.

The overridden base method must have the same signature as the override method.

For information about inheritance, see Inheritance (C# Programming Guide).

You cannot override a non-virtual or static method.

The overridden base method must be virtualabstract, or override.

An override declaration cannot change the accessibility of the virtual method.Both the override method and the virtual method must have the same access level modifier.

You cannot use the newstatic, or virtual modifiers to modify an override method.

An overriding property declaration must specify exactly the same access modifier, type, and name as the inherited property, and the overridden property must be virtualabstract, or override.

For more information about how to use the override keyword,

see Versioning with the Override and New Keywords (C# Programming Guide)

andKnowing when to use Override and New Keywords.

override (C# Reference)的更多相关文章

  1. abstract (C# Reference)

    https://msdn.microsoft.com/en-us/library/sf985hc5.aspx The abstract modifier indicates that the thin ...

  2. Spring3 整合Hibernate3.5 动态切换SessionFactory (切换数据库方言)

    一.缘由 上一篇文章Spring3.3 整合 Hibernate3.MyBatis3.2 配置多数据源/动态切换数据源 方法介绍到了怎么样在Sping.MyBatis.Hibernate整合的应用中动 ...

  3. 浅谈开源项目Android-Universal-Image-Loader(Part 3.1)

    本文转载于:http://www.cnblogs.com/osmondy/p/3266023.html 浅谈开源项目Android-Universal-Image-Loader(Part 3.1) 最 ...

  4. 【Java&Android开源库代码剖析】のAndroid-Universal-Image-Loader-part1

    做Android app开发的同学应该都听说过或者用过nostra13的Android-Universal-Image-Loader开源库,它在图片异步加载.缓存和显示等方面提供了强大灵活的框架.之前 ...

  5. Android -- ImageLoader简析

    图片的内存缓存实现 Image-Loader库有一个较完整的内存缓存实现,使用者可以根据需要选择已经实现的策略,也可以定制自己项目中需要的策略. 内存缓存实现代码在memory和memory.impl ...

  6. Java中的软(弱)引用

    一.Java中的强.软.弱.虚引用 在JDK中我们能够看到有一个java.lang.ref的包.这个包中就是Java中实现强.软.弱.虚引用的包,例如以下: PhantomReference 虚引用: ...

  7. ssh,hibernate动态映射多表

    [From] http://www.07net01.com/2016/01/1172051.html 最近在做OA系统(ssh),一直在想如何把框架架得更完善,此前已经在框架里集成springMVC, ...

  8. [原创] 浅谈开源项目Android-Universal-Image-Loader(Part 3.1)

    最近,总算有时间去做些平时喜欢而没空去做的事情.一直觉得项目中使用的Image Loader适用性不强,昨晚在github随便逛逛,发现一个开源项目Android-Universal-Image-Lo ...

  9. JNDI 笔记(一) 概述

    很多地方都会用到JNDI,一大堆的缩写加上一大堆不清不楚的概念描述,使得在看到的时候都不认识,更不要说使用了.   JNDI,Java Naming Directory Interface,J2EE的 ...

随机推荐

  1. vue 自定义指令使用

    <template> <div> <!-- 让input元素在打开页面的时候就获得焦点 --> <input type="text" v- ...

  2. hadoop_exporter+prometheus

    1.准备工作 安装go.glibe(需要连google服务器,咋连的,我就不写了,因为尝试了各种办法,都失败了,很伤心) 2.下载hadoop_exporter cd /usr/local/prom/ ...

  3. POJ 1988相对偏移

    //不容易啊,终于自己a了一道这种类型的题 // #include<stdio.h> #include<iostream> using namespace std; const ...

  4. 使用Spring-Session共享使用Session

    前言: session共享策略有很多,常见的有粘性复制,高并发下效率查.tomcat-redis-session-manager无疑是一个挺好的方案,缺点要配置tomcat,有点复杂.最优的方案莫过于 ...

  5. 自己打断点走的struts流程&拦截器工作原理

    ①. 请求发送给 StrutsPrepareAndExecuteFilter ②. StrutsPrepareAndExecuteFilter 判定该请求是否是一个 Struts2 请 求(Actio ...

  6. CSU - 1115 最短的名字(字典树模板题)

    Description 在一个奇怪的村子中,很多人的名字都很长,比如aaaaa, bbb and abababab. 名字这么长,叫全名显然起来很不方便.所以村民之间一般只叫名字的前缀.比如叫'aaa ...

  7. spring boot file上传

    用Spring Boot写读取Excel文件小工具的时候遇到的一些小坑已经填平,复制即可满足普通的文件上传功能POI方面只需一个包,其他通用包工程中一般都会带TIPS:前端为了扩展我用ajax异步请求 ...

  8. 洛谷 P1166 打保龄球

    P1166 打保龄球 题目描述 打保龄球是用一个滚球去打击十个站立的柱,将柱击倒.一局分十轮,每轮可滚球一次或多次,以击倒的柱数为依据计分.一局得分为十轮得分之和,而每轮的得分不仅与本轮滚球情况有关, ...

  9. 【c++】【转】如何只在heap上创建对象,如何只在stack上建立对象?

    http://www.cnblogs.com/chio/archive/2007/10/23/934335.html http://blog.csdn.net/szchtx/article/detai ...

  10. 消息驱动bean(MDB)实例

    到眼下为止前面介绍的有关JavaEE的东西都是同步的.也就是说调用者调用某个方法.那么这种方法必须马上运行并返回运行结果. 用官方一些的语言来说就是"client通过业务接口调用一个方法,在 ...