C# method overriding tutorial example explained
#C# #method #override
using System;
namespace MyFirstProgram
{
class Program
{
static void Main(string[] args) {
//method overriding = provides a new version of a method inherited from a parent class
// inherited method must be: abstract, virtual, or already overriden
// Used with ToString(), polymorphism
Dog dog = new Dog();
Cat cat = new Cat();
dog.Speak();
cat.Speak();
Console.ReadKey();
}
}
class Animal
{
public virtual void Speak()
{
Console.WriteLine("The animal goes *brrr*");
}
}
class Dog : Animal
{
public override void Speak()
{
Console.WriteLine("The dog goes *woof*");
}
}
class Cat : Animal
{
}
}
On this page of the site you can watch the video online C# method overriding 🙅 with a duration of hours minute second in good quality, which was uploaded by the user Bro Code 03 July 2021, share the link with friends and acquaintances, this video has already been watched 45,243 times on youtube and it was liked by 1.5 thousand viewers. Enjoy your viewing!