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();
}
}
}
No comments :
Post a Comment