C# does not support multiple inheritance. However, you can use interfaces to implement multiple inheritance. The following program demonstrates this:
namespace MultipleInheritance
{
class A
{
public void disp()
{
Console.WriteLine("disp() method of Class A");
}
}
interface First
{
void mno();
}
interface Second
{
void pqr();
}
class Z:A,First,Second
{
public void mno()
{
console.WriteLine("mno() method is overridden.");
}
public void pqr()
{
console.WriteLine("pqr() method is overridden.");
}
}
}
No comments:
Post a Comment