class Program
{
static void Main(string[] args)
{
Baseclass bc;
bc = new Baseclass();
bc.Show();
bc = new DerivedClass();
bc.Show();
bc = new DerivedClass2();
bc.Show();
Console.ReadLine();
}
}
class Baseclass
{
public void Show()
{
System.Console.WriteLine("Baseclass::Show");
}
}
class DerivedClass : Baseclass
{
new public void Show()
{
System.Console.WriteLine("DerivedClass::Show");
}
}
class DerivedClass2 : Baseclass
{
new public void Show()
{
System.Console.WriteLine("DerivedClass2::Show");
}
}
OutputBaseclass::Show
Baseclass::Show
Baseclass::Show it invokes the functions of the class that matches its Reference bc
bc contains the reference to a particular derived class object, then its supposed to invoke the function of that class