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 are All kind of access specifiers for a class and for methods
What is type cast in C#?
What does void mean in c#?
What is difference between the "throw" and "throw ex" in .net?
What is the difference between wrapper class and primitive?
In which situation(s), the use of "Delegate" is a good idea?
Does hashset allow duplicates c#?
Are c# destructors the same as c++ destructors?
What is a multi line comment?
Is java better than c sharp?
Are multiple data types stored in System.Array?
What is a multicast delegate in c#?
What are the features of c#?
What is the use of getcommandlineargs() method in c#.net?
What is the differences between datagrid, datalist and repeater in .net?