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

Give an example of removing an element from the queue?

647


Is java better than c#?

674


What is difference between a type and class?

787


What is the purpose of static?

682


How to use delegates with events?

746






What is the use of xmlserializer?

628


List down the reason behind the usage of c# language.

857


How do I create a .exe file?

684


Explain the difference between object type and dynamic type variables in c#?

643


Which is better python or c#?

615


What is console read in c#?

659


What does int32 mean?

643


Which is better javascript or c#?

657


What are the two kinds of properties in c#.

670


Why should I use interface in c#?

693