C # How to achieve multiple inheritance, the key is the interface can write the implementation of the method
Namespace Extensions
{
Using System;
Using ExtensionMethodsDemo1;
public static Class Extension
{
Extended interface
public static void MethodB (this imyinterface myinterface)
{
Console.WriteLine ("Extension.methodb (this imyinterface myinterface)");
}
}
}
Namespace ExtensionMethodsDemo1
{
Using System;
Using Extensions;
public interface IMyInterface
{
void MethodB ();
}
Class A:imyinterface
{
public void MethodB () {Console.WriteLine ("A.methodb ()");}
}
Class B:imyinterface
{
public void MethodB () {Console.WriteLine ("B.methodb ()");}
}
Class C:imyinterface
{
public void MethodB () {Console.WriteLine ("C.methodb ()");}
}
Class Extmethoddemo
{
static void Main (string[] args)
{
A A = new A ();
b b = new B ();
c C = new C ();
A.methodb ()
B.methodb ()
C.methodb ()
}
}
}