Created
October 28, 2013 17:06
-
-
Save hagbarddenstore/7200658 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| void Main() | |
| { | |
| var a = new A(); | |
| var b = new B(); | |
| a.One(); | |
| a.Two(); | |
| b.One(); | |
| b.Two(); | |
| var bAsA = (A)b; | |
| bAsA.One(); | |
| bAsA.Two(); | |
| } | |
| class A | |
| { | |
| public virtual void One() | |
| { | |
| Console.WriteLine("Method One in class A"); | |
| } | |
| public void Two() | |
| { | |
| Console.WriteLine("Method Two in class A"); | |
| } | |
| } | |
| class B : A | |
| { | |
| public override void One() | |
| { | |
| Console.WriteLine("Method One in class B"); | |
| } | |
| public new void Two() | |
| { | |
| Console.WriteLine("Method Two in class B"); | |
| } | |
| } |
This file contains hidden or 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
| Method One in class A | |
| Method Two in class A | |
| Method One in class B | |
| Method Two in class B | |
| Method One in class B | |
| Method Two in class A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment