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 thread in c#?
Why do you call it a process? What’s different between process and application in .net, not common computer usage, terminology?
Can enum be null c#?
Is there a way of specifying which block or loop to break out of when working with nested loops?
What is exe file in c#?
How the versioning applies to Assemblies or can you explain version numbers?
Can you have more than one namespace in c#?
Is datetime a value type in c#?
Are tuples immutable c#?
What are the Types of instancing properties and explain each. Explain the difference between multiuse,singleuse and globalmultiuse and which is default
What is this keyword in C#?
Give examples for reference types?
Why do canadians say zed?
Why use a singleton instead of static methods?
What is clr namespace?