What is overriding?

Om ji mishra

Total Post:17

Points:119

Posted by  Om ji mishra
C#
 658  View(s)
Ratings:
Rate this:

What is overriding?            

  1. Re: What is overriding?

     Method Overriding is a technique that allows the use of any functions from another class (base class) in the derived class. Creating a method in the derived class with the same signature as a method in the base class is called method overriding. This is like a virtual method.

    using System; 
    
      class baseClass
    {
     public virtual void show()
       {
            Console.WriteLine("Base class");
        }
    }

    class derived : baseClass
    {
    public override void show()
        {
            Console.WriteLine("Derived class");
          }
    }

    class GFG
    {
    public static void Main()
        {
           baseClass obj;
    obj = new baseClass();
    obj.show();
    obj = new derived();
    obj.show();
         }
    }

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.