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
What is unmannaged code and will CLR handle this kind of code or not .
What is thread in c#?
Can you change the value of a constant filed after its declaration?
What are most desktop applications written in?
Can abstract class instantiated c#?
What kind of the information stored inside the assembly?
What is the difference between decimal and integer?
What is parallel foreach in c#?
What is writeline?
Are enums static c#?
What are escape sequences explain with example?
Describe two uses of the “using” statement during the operation of c#?
How do I start a program in c#?
Give examples for value types?
What is lazy keyword in c#?