- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Virtual vs Sealed vs New vs Abstract in C#
Virtual
The virtual keyword allows a class to be overridden. For overriding a parent class method in the child class, declare the parent class method as virtual.
Sealed
When a class is declared sealed, it cannot be inherited, abstract classes cannot be declared sealed.
To prevent being overridden, use the sealed in C#. When you use sealed modifiers in C# on a method, then the method loses its capabilities of overriding. The sealed method should be part of a derived class and the method must be an overridden method.
public sealed override void getResult() { }
New
Use the new keyword to hide the base class method from the derived class. This is done by declaring the derived class function with new. This is how new is used in Shadowing.
public new string getResult()
Abstract
Abstract classes contain abstract methods, which are implemented by the derived class.
abstract class Vehicle