How do you create multiple inheritance in C#?
Answers were Sorted based on User's Feedback
Answer / p.senthil
C# doesnt support multiple inheritance. So using interfaces
to solve that problem
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / mukesh
C# doesnt support multiple inheritance. by using interfaces
to solve that problem. C# supports multilevel inheritance.
| Is This Answer Correct ? | 3 Yes | 0 No |
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 |
Answer / arunkumar.v
C# doesnt support multiple inheritence ie.,it doesnt
inherit multiple base class.It generally creates confusion.
Instead you can use Interfaces.You are permitted to inherit
one base class and multiple interfaces.
| Is This Answer Correct ? | 2 Yes | 1 No |
What is type safe code?
How to move to a state-related codebase?
Define an array?
Can an abstract class have a constructor c#?
What does == mean in c sharp?
Difference between call by value and call by reference in C#?
How does dll hell solve in .net?
Is datetime nullable c#?
If I want to override a method 1 of class A and in class b then how do you declare ?
What are generics in c#.net?
How do I unload an application domain?
Is std :: string null terminated?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)