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
Explain the difference between abstract class and interface.
Why singleton class is sealed?
What is default method in c#?
Why do we need a singleton class?
Explain the difference between pass by value and pass by reference.
Describe ways of cleaning up objects in c#.
What is a framework in c#?
Is clr a compiler?
What is the namespace for datatable in c#?
What is var c#?
How do I make a dll in c#?
What is the implicit name of the parameter that gets passed into the set method/property of a class?
Is c# used for frontend or backend?
What is definition in c#?
Is var a data type?