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 difference between destruct or and garbage collection ?
Is stringbuilder better than string?
Why do we use interfaces in c#?
How do you convert byte array to hexadecimal string, and vice versa?
What is instantiating a class?
What is multidimensional array in c#?
Define MSIL, and how does it works? Why our developers need an appreciation of it if at all?
How long will it take to learn c sharp?
Why do we need ienumerable in c#?
Can abstract class have private constructor c#?
How you will create satellite assemblies?
What is connection pooling in ado.net?
What is boxing in c#?
What is the C# syntax to catch any possible exception?
How do you implement thread synchronization in c#?