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's new in c#?
How do I use the 'using' keyword with multiple objects?
Can I use exceptions in c#?
Why do we use 0?
What's the difference between the debug class and trace class? Documentation looks the same.
What are the Types of values mode can hold session state in web.config
What exactly is serverless?
What does xpath return?
What is generic method in c#?
What is the advantage of singleton class?
What are data types in C#?
What are the properties of c#?
What is readline library?
What does namespace mean?
What is #region in c#?