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
Can fields inside a class be virtual?
What are destructors in C#?
What is the data provider name to connect to access database?
Is goto statement supported in c#?
how to sort an array in c#
What is xor operation?
What is c# entity framework?
can you allow a class to be inherited, but prevent the method from being over-ridden?
What are All kind of access specifiers for a class and for methods
What are static and dynamic variables?
Is list immutable in c#?
What is the difference between interface and functional interface?
Does unity require coding?
What I can do with c#?
What is COM Interoperability?