Created
March 13, 2017 15:25
-
-
Save yungtechboy1/3abff2bd2e478caef14a6b2cfa8a51fb 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
namespace Polymorphism | |
{ public class A | |
{ | |
private String You_Cant_See = "Boo!0"; | |
public void Foo() | |
{ | |
Console.WriteLine("A::Foo()"); | |
} | |
} | |
class B : A | |
{ | |
public new void Foo() | |
{ | |
Console.WriteLine("B::Foo()"); | |
} | |
class Test | |
{ | |
static void Main(string[] args) | |
{ | |
A a; | |
//B b; | |
a = new A(); | |
b = new B(); | |
a.Foo(); // output --> "A::Foo()" | |
b.Foo(); // output --> "B::Foo()" | |
a = new B(); | |
a.Foo(); // output --> "A::Foo()" | |
//Need it to output B::Foo() inorder for my method to work | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment