Skip to content

Instantly share code, notes, and snippets.

@frockenstein
Created March 20, 2013 16:40
Show Gist options
  • Save frockenstein/5206170 to your computer and use it in GitHub Desktop.
Save frockenstein/5206170 to your computer and use it in GitHub Desktop.
// linqpad example
void Main()
{
Car.Go();
Honda accord = new Honda("accord");
Honda.Go(); // throws an error here - ref to non-static method
}
public class Car
{
public static void Go()
{
"car going".Dump();
}
}
public class Honda : Car
{
public Honda(string model)
{
this.model = model;
}
public new void Go()
{
// this class uses shared state inside of this method
// but breaks because Car.Go is static
this.model + " going".Dump();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment