How do you create multiple inheritance in C#?
Answer Posted / neeraj tyagi
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestApp
{
class MultipleInheritance : first, Isecond
{
Isecond objsecond = new second();
#region Isecond Members
public void secondfunction()
{
objsecond.secondfunction();
}
#endregion
}
class first
{
public first()
{
}
public void firstfunction()
{
Console.WriteLine("First funciton called");
}
}
interface Isecond
{
void secondfunction();
}
class second : Isecond
{
public second()
{
}
public void secondfunction()
{
Console.WriteLine("Second function called");
}
}
class Program
{
static void Main(string[] args)
{
//multiple inheritance
MultipleInheritance obj = new MultipleInheritance();
obj.firstfunction();
obj.secondfunction();
Console.ReadLine();
}
}
}
| Is This Answer Correct ? | 47 Yes | 19 No |
Post New Answer View All Answers
What is object array in c#?
How to update the gui from another thread in c#?
What is reflection c#?
What is the difference between a variable and a literal?
What is ildasm.exe used for?
How can encapsulation be achieved?
What is function c#?
What is the major difference between a custom control and user control?
Is versioning applicable to private assemblies?
What is uint16?
How do you convert byte array to hexadecimal string, and vice versa?
Is typeof c#?
What's c# ?
What is difference between array and collection in c#?
What are winforms in c#?