Programming C# 2.0, 3.0, 4.0: Muhammed Ali Sakhi Microsoft Certified Trainer
Programming C# 2.0, 3.0, 4.0: Muhammed Ali Sakhi Microsoft Certified Trainer
© PakDev.net
Agenda
Inheritance
Polymorphism
Sealed Classes
© PakDev.net
Inheritance
Ability to reuse, extend, and modify another
classes
© PakDev.net
Inheritance
The derived class implicitly gains all the
members of the base class, except constructors
and destructors
© PakDev.net
Calling base Class Constructors
Constructor declaration must use base keyword
© PakDev.net
Polymorphism
A derive class can override base class methods
Use the virtual keyword in base class
Use the override keyword in the child classes
Virtual methods cannot be static or private
Override methods cannot be static or override
You cannot override a non virtual method
Override methods cannot be explicitly virtual
You can override an override method
© PakDev.net
Using Sealed Classes
You cannot derive from a sealed class
© PakDev.net
Inheritance
Demo
© PakDev.net
Thank you
PakDev.net
© PakDev.net