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

Which namespaces are necessary to create a localized application?

615


Explain About namespaces

579


Why do we need to call CG.SupressFinalize?

555


Define xslt.

547


How to use delegates with events?

553






What is the difference between string and stringbuilder in c#?

471


Is string null or empty?

513


Explain how to add controls dynamically to the form using c#.net.

553


Is python easier than c#?

497


Can constructor be overloaded in c#?

479


What is a console operator?

490


What does ienumerable mean?

482


When should we use delegates in c#?

490


Are structs value types c#?

474


Which of the following API is used to hide a window?

535