
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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 Multi-Level Inheritance
Multilevel Inheritance occurs when a derived class is formed from another derived class.
Grandfather, father, and son are the perfect example to represent Multilevel Inheritance in C# −
Example
The following is an example stating the usage of multilevel inheritance in C#.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class Son : Father { public void DisplayTwo() { Console.WriteLine("Son.. "); } static void Main(string[] args) { Son s = new Son(); s.Display(); s.DisplayOne(); s.DisplayTwo(); Console.Read(); } } class Grandfather { public void Display() { Console.WriteLine("Grandfather..."); } } class Father : Grandfather { public void DisplayOne() { Console.WriteLine("Father..."); } } }
Output
Grandfather... Father... Son..
Advertisements