Karcki Ramani

Karcki Ramani

  • NA
  • 12
  • 2.1k

Dynamic polymorphism

Feb 1 2016 6:08 AM
I have the following program and my need is call the parent class method using parent class reference which points to child class object.
 
class aa
{
public virtual void test()
{
Console.WriteLine("test in parent class");
}
}
class chi:aa
{
public override void test()
{
Console.WriteLine("test in child class");
}
}
class Program:chi
{
static void Main(string[] args)
{
aa ref1 =new chi();
ref1.test();
}
}
}
I need to class the test method  of class "aa" using the reference ref1. how to do this?
Please help 

Answers (1)