Simple Inheritance in C#

Bhuvanesh6
Posted by Bhuvanesh6 under C# category on | Points: 40 | Views : 1185
This is the code to explain Simple inheritance using C#.

using System;

namespace BhuvanSample
{
public class SampleInheritance
{
static void Main(string[] args)
{
Parenting parents = new Parenting();
parents.Teaching();
Child kid = new Child();
kid.Learning();
kid.Teaching();
Console.ReadKey();
}
class Parenting
{
public void Teaching()
{
Console.WriteLine("Teach");
}
}
class Child : Parenting
{
public void Learning()
{
Console.WriteLine("Learn");
}
}

}
}


Comments or Responses

Login to post response