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
Why we use dll in c#?
When can a derived class override a base class member?
Can you access a hidden base class method in the derived class?
Why is ienumerable used?
Is static thread safe?
Why does dllimport not work for me?
What is string empty?
What is a dll in c#?
What is the difference between selection and projection?
What is verbatim literal in c#?
What is eager and lazy loading in c#?
Is string a data type in c#?
Can we have multiple threads in one app domain?
What are the Types of assemblies that can be created in dotnet
If I want to override a method one of class A and in class b then how do you declare?