Inheritance c#
Inheritance c#
INHERITANCE IN C#
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() {};
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...