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 ?    47 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain hash table in c# ?

835


What is function c#?

658


How do I open the console?

754


What is difference between abstraction and encapsulation in c#?

729


What is int32?

675


How many types of constructors are there in c#?

629


Why c# is called c sharp?

640


What is type safe in c#?

653


What is the use of delegate?

712


What is difference between int and int in c#?

635


What does void do in unity?

691


What are reflections in c#?

674


Can we have static indexer in c#?

667


What is iqueryable and ienumerable in c#?

698


What is the differences between datagrid, datalist and repeater in .net?

692