Home > Software > .NET > Dot-Net
Interview Questions   Tutorials   Discussions   

Dot-Net - How do you achieve multilevel inheritance in .NET ?




356
views
asked mar October 5, 2014 03:21 PM  

How do you achieve multilevel inheritance in .NET ?


           

1 Answers



 
answered By siddhant   0  

This C# Program Illustrates Multilevel Inheritance with Virtual Methods. Here the system executes the first override-virtual method found in the hierarchy. Here is source code of the C# Program to Illustrate Multilevel Inheritance with Virtual Methods. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

using System;
public class Person
{
    protected string RNO = "44";
    protected string name = "Ram";
    public virtual void GetInfo()
    {
        Console.WriteLine("Name: {0}", name);
        Console.WriteLine("RNO: {0}", RNO);
        Console.WriteLine();
    }
}
class Student : Person
{
    public string id = "ABC";
    public override void GetInfo()
    {
        base.GetInfo();
        Console.WriteLine("Student ID: {0}", id);
    }
}
class Stud : Student
{
    private string StudentAddress = "USA";
    public void GetInfo()
    {
        base.GetInfo();
        Console.WriteLine("Student Address: {0}", StudentAddress);
    }
}
class TestClass
{
    public static void Main()
    {
        Student E = new Student();
        E.GetInfo();
        Stud Stud = new Stud();
        Stud.GetInfo();
        Console.ReadLine();
    }
}
flag   
   add comment

Your answer

Join with account you already have

FF

Preview

 Write A Tutorials
Online-Classroom Classes
www.writeabc.com


  1 person following this question

  1 person following this tag

  Question tags

Asked 2 years and 3 months ago ago
Number of Views -356
Number of Answers -1
Last updated
3 years and 2 months ago ago

Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert