INHERITANCE IN C#
INHERITANCE IN C#
This presentation will explain what is
inheritance why it matters, and provide an
example to help you understand.
WHAT IS INHERITANCE?
Definition: Inheritance in C# means a child class can share and use
the functions and properties of a parent class. This makes it easier
to reuse code and keep programs organized
WHAT IS INHERITANCE?
Definition: Inheritance in C# means a child class can share and use
the functions and properties of a parent class. This makes it easier
to reuse code and keep programs organized
Key Points:
• Helps organize classes in a structured way, like family tree.
• Avoid repetitive code
• Base class: the main class with common features
• Derived class: the new class that adds or changes features from the base
INHERITANCE EXAMPLE
Base Class
ANIMAL
• String Name;
• Int Age;
• Void Eat() {};
• Void Sleep() {};
INHERITANCE EXAMPLE
Base Class
ANIMAL
• String Name;
• Int Age;
• Void Eat() {};
• Void Sleep() {};
Derived Class Derived Class
Dog Bird
Inherit 'Animal ' Inherit 'Animal '
• String Name; into Dog class into bird class • String Name;
• Int Age; • Int Age;
• Void Eat() {}; • Void Eat() {};
• Void Sleep() {}; • Void Sleep() {};
• Void Walk() {}; • Void Walk() {};
• Void Fly() {};
THANK YOU...
The End of Topic