Created
August 24, 2012 21:16
-
-
Save pec1985/3455700 to your computer and use it in GitHub Desktop.
SubClassing in C#
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
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