Microsoft.NET 2.0 Question:
Download Questions PDF

How to create multiple inheritance inc#, with example?

Answer:

A class can implement multiple interfaces.

public class A : Ix, Iy,Iz

This way you can achieve multiple inheritence

In C#, a class cannot have multiple inheritance with classes. But class can have multiple inheritance with one class and more than one interface.

Eg:

namespace TestClass
{
public class A
{
public void testA()
{
Console.WriteLine("In Class A");
}
}
interface IB
{
void testIB();
}
interface IC
{
void testIC();
}

public class Test : A, IB, IC
{
public void testIB()
{
Console.WriteLine("In Interface IB");
}
public void testIC()
{
Console.WriteLine("In Interface IC");
}
}
class Program
{
static void Main(string[] args)
{

Test tt = new Test();
tt.testA();
tt.testIB();
tt.testIC();
Console.ReadLine();
}
}
}

Download Microsoft.NET 2.0 Interview Questions And Answers PDF

Previous QuestionNext Question
Consider a datagrid in windows application. Here item, rate, qty, amount field are there. When user enters rate and qty, amount should be automatically calculated. When enter key is pressed, the cursor should go from item to rate and then qty and then amount. But amount should be automatically calculated. In Grid when button is clicked, then and then only new row should be created and another button is clicked, row should be removed.Thus give me the solution?Explain Can 2 different applications use the same dll in GAC at the same time?