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 parallel foreach c#?
can multiple catch blocks be executed for a single try statement?
What are delegates?
When Should You Call The Garbage Collector In .net?
Explain the difference between .net and c#?
Which attribute adorn a test class to be picked up by the NUnit GUI in the NUnit test framework?
What?s the difference between <c> and <code> XML documentation tag?
Why is c# used?
What is the max value of int32 in c#?
What is the concept of strong names?
Contrast System.String and System.Text.StringBuilder classes?
What is an abstract class c#?
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)