Skip to content

Instantly share code, notes, and snippets.

@kurulerdem
Created August 28, 2020 06:48
Show Gist options
  • Save kurulerdem/5214515f6b2d47d879d5670f0ff22917 to your computer and use it in GitHub Desktop.
Save kurulerdem/5214515f6b2d47d879d5670f0ff22917 to your computer and use it in GitHub Desktop.
Virtual Methods
using System;
namespace VirtualMethod
{
class Program
{
static void Main(string[] args)
{
Tesla tesla = new Tesla();
tesla.Drive();
}
}
class Car
{
public virtual void Drive()
{
Console.WriteLine("Driving Manual");
}
}
class Tesla : Car
{
public override void Drive()
{
Console.WriteLine("Driving Auto");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment