Smart    Lucky

Smart Lucky

  • NA
  • 555
  • 637.7k

New Keyword in Polymorphism

Jan 3 2012 5:35 AM
Hi
can any one tell me what is doing new Keyword i am not understanding



class BC
{
    public void Display()
    {
        System.Console.WriteLine("BC::Display");
    }
}


class DC : BC
{
    new public void Display()
    {
        System.Console.WriteLine("DC::Display");
    }
}
class TC : DC
{
    new public void Display()
    {
        Console.WriteLine("TC::Display");
    }
}


class Demo
{
    public static void Main()
    {
        DC b;
        b = new DC();
        b.Display();
        b = new TC();
        b.Display();
        //b = new TC();
        //b.Display();
    }
}

Answers (6)