How do you create multiple inheritance in C#?

Answer Posted / neeraj tyagi

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestApp
{
class MultipleInheritance : first, Isecond
{
Isecond objsecond = new second();

#region Isecond Members

public void secondfunction()
{
objsecond.secondfunction();
}

#endregion
}
class first
{
public first()
{
}

public void firstfunction()
{
Console.WriteLine("First funciton called");
}
}
interface Isecond
{
void secondfunction();
}
class second : Isecond
{
public second()
{
}

public void secondfunction()
{
Console.WriteLine("Second function called");
}
}

class Program
{
static void Main(string[] args)
{
//multiple inheritance
MultipleInheritance obj = new
MultipleInheritance();
obj.firstfunction();
obj.secondfunction();

Console.ReadLine();
}
}
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between abstract class and interface.

805


Why singleton class is sealed?

686


What is default method in c#?

690


Why do we need a singleton class?

693


Explain the difference between pass by value and pass by reference.

721


Describe ways of cleaning up objects in c#.

675


What is a framework in c#?

656


Is clr a compiler?

646


What is the namespace for datatable in c#?

706


What is var c#?

665


How do I make a dll in c#?

688


What is the implicit name of the parameter that gets passed into the set method/property of a class?

692


Is c# used for frontend or backend?

799


What is definition in c#?

635


Is var a data type?

708