Here is an Inheritance question. I was trying to understand TAG1 to TAG3 Process. what exactly going happen and hold which class reference. Looking forward to your suggestion.
static void Main(string[] args) { B b = new B(); **// What Happens here TAG1** A a = b; **//What Happens here TAG2** B x = new A() as B; **//what happens here TAG3** a.F(); a.G(); a.H(); a.Z(); b.F(); b.G(); b.H(); b.Z(); x.F(); Console.ReadLine(); } public class A { public void F() { Console.WriteLine("A.F"); } public virtual void G() { Console.WriteLine("A.G"); } public virtual void H() { Console.WriteLine("A.H"); } public void Z() { Console.WriteLine("A.Z"); } } public class B : A { new public void F() { Console.WriteLine("B.F"); } public override void G() { Console.WriteLine("B.G"); } new public void H() { Console.WriteLine("B.H"); } }