Inheritance means parent-child relationship.By using Inheritance methodology we can create a new class by using existing class code ( reuse existing methods, properties ).It also referred to as reusability of the code so by using Inheritance we can reuse the code again and again.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
namespace Forum
{
public class ParentClass
{
public void ParentCall()
{
Console.WriteLine("Called Parent Class."); }
}
public class ChildClass : ParentClass
{
public void ChildCall()
{
Console.WriteLine("Called Child Class.");
}
static void Main(string[] args)
{
ChildClass child = new ChildClass();
child.ParentCall();
child.ChildCall();
Console.ReadLine();
}
}
}
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Inheritance means parent-child relationship.By using Inheritance methodology we can create a new class by using existing class code ( reuse existing methods, properties ).It also referred to as reusability of the code so by using Inheritance we can reuse the code again and again.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
namespace Forum
{
public class ParentClass
{
public void ParentCall()
{
Console.WriteLine("Called Parent Class."); }
}
public class ChildClass : ParentClass
{
public void ChildCall()
{
Console.WriteLine("Called Child Class.");
}
static void Main(string[] args)
{
ChildClass child = new ChildClass();
child.ParentCall();
child.ChildCall();
Console.ReadLine();
}
}
}