public interface IA { string getA(); }public interface IB:IA { string getB(); }public class A:IA { public string getA(){return this.GetType().Name+"getA";} }public class B:IB { public string getA(){return this.GetType().Name+"getA";} public string getB(){return this.GetType().Name+"getB";} }如果B派生A,只要实现IB接口的声明,因为A已经实现了 public class B:A { public string getB(){return this.GetType().Name+"getB";} }IA a=new A(); IA b1=new B(); IB b2=new B(); A b3=new B(); 以上看明白了吗,B它实现了IA,IB和A,它既可以是IA也可以是IB,当然还有它的父类A
{
string getA();
}public interface IB:IA
{
string getB();
}public class A:IA
{
public string getA(){return this.GetType().Name+"getA";}
}public class B:IB
{
public string getA(){return this.GetType().Name+"getA";}
public string getB(){return this.GetType().Name+"getB";}
}如果B派生A,只要实现IB接口的声明,因为A已经实现了
public class B:A
{
public string getB(){return this.GetType().Name+"getB";}
}IA a=new A();
IA b1=new B();
IB b2=new B();
A b3=new B();
以上看明白了吗,B它实现了IA,IB和A,它既可以是IA也可以是IB,当然还有它的父类A
而A的派生类B要实现接口IB,这时如果IB继承与IA会发生什么啊?由于A实现了接口IA,而B又继承A,所以B自然也就从A继承了对于IA的实现,又B实现了IB...所以综上可知,A仅实现IA,而B中既包括IA的实现,也包括IB的实现....楼主所说的"如果IB继承与IA会发生什么啊"是指什么啊?