SEARCH C# PROGRAMMING CODES HERE

Overriding methods

Overriding methods in C#
Overriding methods override a base class technique in a derived class by making a technique with the same name and parameters by utilizing virtual and override keywords.To perform this task you have to utilize virtual keyword with base class technique and abrogate catchphrase with override keyword with derived class strategy.
Programa

using System;

    namespace Method_Overriding
    {
        public class A   /* Base Class*/
        {
          
            public virtual void Get_Detail()
            {
                Console.WriteLine("Apple");
            }
        }

        public class B : A    /* Derived Class */
        {
            public override void Get_Detail()
            {
                Console.WriteLine("Bat");
            }
        }
        class Program
        {
            static void Main(string[] args)
            { 
              /* Calling */
              A a = new A();
              a.Get_Detail();
              B b = new B();
              b.Get_Detail();
              Console.ReadKey();
            }
        }
    }

Output
Apple
Bat