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 accessibility modifier protected internal?
What is difference between an Structure and Class?
What is an assembly qualified name? Is it a filename? How is it different?
Why do we use methods in c#?
What is the difference between method parameters and method arguments. Give an example?
What is helper method in c#?
Is it possible to inherit multiple interfaces?
Can property be private in c#?
How does c# generics and c++ templates compare?
What does out mean in c#?
Explain the use of Mutex in C#?
How do you mark a method obsolete?
Name some properties of array.
What is array c#?
What does char mean in c#?