How do you create multiple inheritance in C#?

Answers were Sorted based on User's Feedback



How do you create multiple inheritance in C#?..

Answer / shafi syed

C# does'nt support multiple inheritance. In that situation
we use interface

Is This Answer Correct ?    108 Yes 8 No

How do you create multiple inheritance in C#?..

Answer / jiten

if u want to crate multile inheritance in C#

u can use intface

Is This Answer Correct ?    98 Yes 10 No

How do you create multiple inheritance in C#?..

Answer / 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

How do you create multiple inheritance in C#?..

Answer / pavankumar

C# doesn't support Multiple Inheritance,,,SO to over come this problem Interface came into picture.Interface is not a class,but it is a parent to base class.

Interface Forest
{
void Greet();
}

class Animal: Forest
{
public void Greet()
{
Console.WriteLine("Animal says Hello");
}

public void Sing()
{
Console.WriteLine("Animal Sings");
}
}

class Program : Animal,Forest
{
static void Main(string[] args)
{
Program obj = New Program();
obj.Greet();
obj.Sing();
Console.ReadLine();
}
}

Is This Answer Correct ?    5 Yes 3 No

How do you create multiple inheritance in C#?..

Answer / frank

using System;

interface Interdemo
{
void Show();
}

class Interimp:Interdemo
{
public void Show()
{
Console.WriteLine("Show() method Implemented");
}

public static void Main(string[] args)
{
Interimp inter = new Interimp();
inter.Show();
}
}

Is This Answer Correct ?    36 Yes 36 No

Post New Answer

More C Sharp Interview Questions

Can abstract class have private constructor c#?

0 Answers  


Why is aws serverless?

0 Answers  


What is mvc in c#?

0 Answers  


What is the different types of private assembly and shared assembly?

0 Answers  


What is the .net datatype that allows the retrieval of data by a unique key?

0 Answers  






Can a structure be inherited by a class?

3 Answers  


can you allow a class to be inherited, but prevent the method from being over-ridden?

0 Answers   Siebel Systems,


What is the difference between list and array in c#?

0 Answers  


how to Create a datagridview control with check box column with 8rows in it, the maximum number of check boxes checked should be 3, when user checks the 4th corresponding message should be displayed and check box should be checked. User can uncheck the checked boxes Note: read-only property should not be used

0 Answers   HCL, NIC,


What is the use of giving more than one CATCH BLOCK in one TRY block? Directly we can give that catch(Exception e)?Why we go for arrayoutofbound Exception,divided by zero etc..? Explain

2 Answers  


What are circular references? How garbage collection deals with circular references.

0 Answers  


Explain About delegates

0 Answers   TCS,


Categories