Skip to content

Instantly share code, notes, and snippets.

@pec1985
Created August 24, 2012 21:16
Show Gist options
  • Save pec1985/3455700 to your computer and use it in GitHub Desktop.
Save pec1985/3455700 to your computer and use it in GitHub Desktop.
SubClassing in C#
public class Shape
{
virtual public int GetHeight()
{
return 101;
}
}
public class Square : Shape
{
public int GetWidth()
{
return 23;
}
// Is this is correct way to override?
override public int GetHeight()
{
return 202;
}
}
/*
* var box = new Square();
* var height = box.GetHeight();
* var width = box.GetWidth();
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment