
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
- Related Questions & Answers
- Abstract vs Sealed Classes vs Class Members in C#
- malloc() vs new() in C/C++
- C++ vs C++0x vs C++11 vs C++98
- Default virtual behavior in C++ vs Java
- C++ vs Java vs Python?
- Tokens vs Identifiers vs Keywords in C++
- Const vs Static vs Readonly in C#
- enum vs. const vs. #define in C/C++
- OneDrive vs Dropbox vs Google Drive vs Box
- Regular cast vs. static_cast vs. dynamic_cast in C++
- Virtual Private Server (VPS) vs. Virtual Private Network (VPN)
- C++ vs C#
- mysql_fetch_array vs mysql_fetch_assoc vs mysql_fetch_object?
- Corona vs. Phonegap vs. Titanium
- Regular cast vs. static_cast vs. dynamic_cast in C++ program