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
Give an example of removing an element from the queue?
Is java better than c#?
What is difference between a type and class?
What is the purpose of static?
How to use delegates with events?
What is the use of xmlserializer?
List down the reason behind the usage of c# language.
How do I create a .exe file?
Explain the difference between object type and dynamic type variables in c#?
Which is better python or c#?
What is console read in c#?
What does int32 mean?
Which is better javascript or c#?
What are the two kinds of properties in c#.
Why should I use interface in c#?