How to call base class methods from derived class in c# programming

Its a concepts of inheritance, child class derived from base class or you can say, a class inherits property from other class known as derived class or child class.
This example cover, If you want to access base class method into child class, you should use base keyword for that. lets take an simple example to demonstrate of this.

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

namespace ConsoleApplication8
{
    class Program
    {
       
        static void Main(string[] args)
        {

            abc obj = new abc();
            Console.ReadKey();

        }
        public void getg()
        {
            Console.WriteLine("base class");

        }
    }
    class abc : Program
    {
        public abc()
        {
            base.getg();
            Console.WriteLine("Child class");

          
        }
    }
}

Code generate the following output

How to call base class methods from derived class in c# programming

Comments

Popular posts from this blog

difference between structure and union in C Language

Difference between Linear search and Binary Search in c language

Difference between static and dynamic websites