 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Example for Hierarchical Inheritance
More than one class is inherited from the base class in Hierarchical Inheritance.
In the example, our base class is Father −
class Father {    public void display() {       Console.WriteLine("Display...");    } } It has Son and Daughter as the derived class. Let us how to add a derived class in Inheritance −
class Son : Father {    public void displayOne() {       Console.WriteLine("Display One");    } } Example
The following the complete example of implementing Hierarchical Inheritance in C# −
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Inheritance {    class Test {       static void Main(string[] args) {          Father f = new Father();          f.display();          Son s = new Son();          s.display();          s.displayOne();          Daughter d = new Daughter();          d.displayTwo();          Console.ReadKey();       }       class Father {          public void display() {             Console.WriteLine("Display...");          }       }       class Son : Father {          public void displayOne() {             Console.WriteLine("Display One");          }       }       class Daughter : Father {          public void displayTwo() {             Console.WriteLine("Display Two");          }       }    } }Advertisements
 