I was just tying to understand what is happening when I write a=c; when I checked type of "a" it is showing up as class "C". Now my question here is if "a" is pointing to "c" then why it is not behaving like pointer "c".
class Program
{
static void Main(string[] args)
{
C c = new C();
A a = new A();
Console.WriteLine(a.GetType());
a = c;
Console.WriteLine(a.GetType());
a.Show();
c.Show();
Console.ReadLine();
}
}
class A
{
public virtual void Show()
{
Console.WriteLine("A.Show()");
}
}
class B : A
{
public override void Show()
{
Console.WriteLine("B.Show()");
}
}
class C : B
{
public new void Show()
{
Console.WriteLine("C.Show()");
}
}
Output: