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
What is a linked list c#?
What is the use of console readline () in c#?
What is difference between abstract class and interface in c#?
How do I move from one form to another in c#?
How can you access a private method of a class?
State two different types of access modifiers.
Which are the access modifiers available in c#?
Why can’t struct be used instead of class for storing entity?
What is a clr host?
What is default c#?
What is the major difference between a custom control and user control?
What does out mean c#?
In which order the constructor is called for an inherited class?
What is the difference between System.console.WriteLine() and System.console.Write() function?example?
What does clr stand for?