Created
August 28, 2020 06:48
-
-
Save kurulerdem/5214515f6b2d47d879d5670f0ff22917 to your computer and use it in GitHub Desktop.
Virtual Methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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