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 I use parseint?
Which string method is used for concatenation of two strings in c#?
What is the difference between hashtable and dictionary?
What is the implicit name of the parameter that gets passed into the set method/property of a class?
What are the advantages of clr procedure over t-sql procedure?
What is the difference between a private assembly and a shared assembly?
Is dll a library?
Please write a program to display “welcome to bestinterviewquestion.com” in c#?
How are Windows programs different from normal C-programs?
What is private void in c#?
What is parameter c#?
Which property do we set on a Combo Box to display data on it prior to setting the DataSource ?
How to declare a property in a class?
Classes and structs can be declared as static, is this statement true or false?
What is void in c#?