【发布时间】:2013-12-03 02:54:43
【问题描述】:
所以我从 stackoverflow 看到了这个例子 使用接口实现多重继承。
interface ILARGESimulator
{
}
interface IUDPClient
{
}
class UDPClient : IUDPClient
{
}
class LargeSimulator : ILARGESimulator
{
}
class RemoteLargeSimulatorClient : IUDPClient, ILargeSimulator
{
private IUDPClient client = new UDPClient();
private ILARGESimulator simulator = new LARGESimulator();
}
那家伙说 “不幸的是,您需要为成员编写包装方法。C# 中不存在多重继承。但是您可以实现多个接口。”
为什么我们还是要从这两个接口继承?
class RemoteLargeSimulatorClient : IUDPClient, ILargeSimulator
如果你有一个has-a关系并调用派生类的基对象,为什么还要写:IUDP, ILargeSimulator?
会不会很简单
class RemoteLargeSimulatorClient
{
好吃吗?
【问题讨论】: