How do you create multiple inheritance in C#?

Answer Posted / pavankumar

C# doesn't support Multiple Inheritance,,,SO to over come this problem Interface came into picture.Interface is not a class,but it is a parent to base class.

Interface Forest
{
void Greet();
}

class Animal: Forest
{
public void Greet()
{
Console.WriteLine("Animal says Hello");
}

public void Sing()
{
Console.WriteLine("Animal Sings");
}
}

class Program : Animal,Forest
{
static void Main(string[] args)
{
Program obj = New Program();
obj.Greet();
obj.Sing();
Console.ReadLine();
}
}

Is This Answer Correct ?    5 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c# used?

471


What is generic collection in c#?

493


What is an inheritance in c#?

486


Explain the Abstract class in c#.net

545


How can it prevents DLL Hell assembly versioning in .NET?

520






What is difference between il and dll ?

522


What are the advantages of using c#?

500


Can dictionary have duplicate keys c#?

486


How much time will it take to learn unity?

462


What is Assembly. and Describe type of assembly. why most developer happy with private assembly.

568


What language is c# similar to?

477


What is the task perform by clr?

561


What is dao in c#?

483


What is ac callback?

493


What are some examples of desktop applications?

492