Given 2 Types
class A { public virtual void Hello() { Console.WriteLine("A"); } }
class B : A { public override void Hello() { Console.WriteLine("B"); } }
and an instance of 'B'
B b = new B();
Can I access the Hello()
method of A
thru b
? (I can think of exposing A as property in B but not sure if there is another way)
I knew this is possible in c++ but was scratching my head in c#.
PS:Please no conversations around 'why do you want this?' or 'this is a bad design' etc.
Not from the outside.
From the inside, the instance can call that, via base.Hello()
, so you could add a:
public void Foo() { base.Hello(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With