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 do you understand by the terms datareader object and dataset object?
What are cshtml files?
Could you explain the difference between func vs action vs predicate?
Why is static constructor called first?
what is the index value of the first element in an array?
What is difference between il and dll ?
Does c# support multilevel inheritance?
Explain About web methods and its various attributes
What floating point types is supported in C#?
What are the commonly used i/o classes?
What is for loop in c#?
What is poco c#?
If you donot specify an access modifier for a method, what is the default access modifier?
What is difference between continue and break in c#?
What is the use of ienumerable?