Skip to content

Instantly share code, notes, and snippets.

@sunmeat
Created October 7, 2025 05:02
Show Gist options
  • Save sunmeat/a256893d882e326e02226cd87b7e7e91 to your computer and use it in GitHub Desktop.
Save sunmeat/a256893d882e326e02226cd87b7e7e91 to your computer and use it in GitHub Desktop.
early binding C#
class Transport
{
public void Drive()
{
Console.WriteLine("Transport::Drive()");
}
}
class Car : Transport
{
public new void Drive()
{
Console.WriteLine("Car::Drive()");
}
}
class Bike : Transport
{
public new void Drive()
{
Console.WriteLine("Bike::Drive()");
}
}
class Tram : Transport
{
public new void Drive()
{
Console.WriteLine("Tram::Drive()");
}
}
class Program
{
static void Main()
{
Car c = new Car();
Bike b = new Bike();
c.Drive();
b.Drive();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment