[TODAY] Enabling the Mobile Workforce


Definition - What does Override mean?

Override, in C#, is a keyword used to replace a virtual member that is defined in a base class with the definition of that member in the derived class.

The override modifier allows programmers to specify the specialization of an existing virtual member inherited from a base class to provide a new implementation of that member in the derived class. It can be used with a method, property, indexer or an event that needs to be modified or extended in a derived class.

The override modifier is intended to implement the concept of polymorphism in C#.

Override differs from new modifiers in that the former is used only to override a virtual member of a base class while the latter also helps to override a non-virtual member defined in a base class by hiding the definition contained in the base class.

Techopedia explains Override

Override is mostly used in the context of virtual method, in which the execution of a type of method is determined by the runtime type of the instance on which the method is invoked. During the invocation, the caller need not know that the called object was an instance of derived class.

For example, if Shape is a base class that provides the basic implementation that is common for all the objects of its class, it can be defined with a virtual method, CalculateArea. Square can be a class derived from Shape, which can override the CalculateArea method to implement the logic necessary for calculating the area of a square.

To override a method in a derived class:

  • The method in the base class has to be declared with virtual modifier.
  • The method in the base class can be abstract but not static.
  • The access modifier of the method in both base and derived classes should be the same.
  • The method should be defined with the same signature in both derived and base classes.
This definition was written in the context of C#
Share this:

Connect with us

Email Newsletter

Join thousands of others with our weekly newsletter

The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.