6
Answers

New Keyword in Polymorphism

Smart    Lucky

Smart Lucky

12y
1.9k
1
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)