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 ? | 2 Yes | 0 No |
Post New Answer View All Answers
Is concurrent queue thread safe?
What is the difference between interface and inheritance in c#?
What you mean by inner exception in c#?
What do u mean by delegation?
What is nullable types in c#?
What is ispostback c#?
How can you reference current thread of the method ?
Why do we use dictionary in c#?
Why do I get a "cs5001: does not have an entry point defined" error when compiling?
Can class inherit from struct c#?
What is difference between dynamic and var in c#?
What is the difference between == and object.equals?
Is c# good for games?
What is difference between new and override in c#?
Tell me the difference between value passing and address passing?