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
Is a decimal an integer?
What is class method c#?
What is polymorphism in c sharp?
Explain the term inheritance in C#.
Why to use “using” in c#?
What is enum in c#?
Is exe is machine dependent?
What is called method in c#?
What are the types of methods in c#?
Why we use extension methods in c#?
What is a void c#?
What is the difference between properties and indexer in c#?
What is the difference between method parameters and method arguments. Give an example?
What do you know about device context?
Expalin the way you implement inheritance by using VB.NET/C#?