Inheritance
A class extends another with a colon. virtual and override change behaviour and base calls the parent.
Example
Animal a = new Cat();
Console.WriteLine(a.Speak());
class Animal { public virtual string Speak() => "..."; }
class Cat : Animal { public override string Speak() => base.Speak() + " meow"; }Exercise
Parent method call.
.Speak()Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.