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.
The base class that is accessed is the base class specified in the class declaration. For example, if you specify class childclass : baseclass, the members of baseclass are accessed from childclass, regardless of the base class of baseclass.
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.
The base class that is accessed is the base class specified in the class declaration. For example, if you specify class childclass : baseclass, the members of baseclass are accessed from childclass, regardless of the base class of baseclass.
Lets take an simple example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication8
{
class Program
{
public Program ()
{
Console .WriteLine ("Base class Constructor");
}
static void Main(string[] args)
{
abc obj = new abc();
Console.ReadKey();
}
}
class abc : Program
{
public abc():base()
{
Console.WriteLine("Child Class");
}
}
}