locked
Using New Keyword RRS feed

  • Question

  • Hi guys can any one explain me the functionality of using of New Keyword.Because i worked on that and in the below code i got some doubt i.e., even though i remove the new keyword i was getting the same Output. so what is the use of it.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication1
    {
        class Base
        {
            public void Display()
            {
                Console.WriteLine("Base Class");
            }
        }
        class derived : Base
        {
            public new  void Display()
        {
            Console.WriteLine("Derived Class");
        }
        }
        class Program
        {
            static void Main(string[] args)
            {
                derived d = new derived();
                d.Display();
                Console.ReadLine();
            }
        }
    }

    Thursday, February 28, 2013 8:35 AM

Answers