Definition - What does Derived Class mean?
A derived class, in the context of C#, is a class created, or derived from another existing class. The existing class from which the derived class gets created through inheritance is known as base or super class.
While inheriting from base class, the derived class implicitly inherits all the members (except constructors and destructors) which it reuses, extends and modifies the behavior of the base class. The derived class overrides the properties and methods of the base class so that it represents the specialized version of base class. C# provides ability to override and hide methods of base class in derived class which makes both classes to evolve freely and maintain binary compatibility.
Techopedia explains Derived Class
Following are some of the features of derived classes in C#:
- As in Java and unlike C++, a derived class cannot have more than one base class but can be derived from more than one interface. However, it inherits all the members of its parent base classes declared in its inheritance hierarchy, due to transitive nature of inheritance
- Access modifiers used in the declaration statement of derived class specify the permissions to use members of its base class
- Code in the constructor of a derived class which is executed during its creation, will be executed only after executing constructor of its base class
- Derived class has to use the modifier, ‘override’ to declare the virtual method (declared in its base class with ‘virtual’ keyword) that has to be overridden. Only instance methods and properties can be overridden
- Derived class can have new method that hides the virtual method declared in base (with similar signature) by using the keyword, ‘new’. To access the method in base class from derived class, ‘base’ keyword can be used
- A class can prevent derivation by declaring it as ‘sealed’ and cannot be used as base class
- A derived class with base class as an abstract class can be instantiated if the derived class is not declared abstract and derived class has the implementation for all abstract methods declared in the base class