相关疑难解决方法(0)

为什么C#在实现接口时不允许继承返回类型

有没有合理的理由说明为什么下面的代码在C#中不合法?

class X: IA, IB
{
    public X test() // Compliation Error, saying that X is not IB
    {
        return this;
    }
}

interface IA 
{
    IB test();
}
interface IB { };
Run Code Online (Sandbox Code Playgroud)

.net c#

23
推荐指数
3
解决办法
3179
查看次数

标签 统计

.net ×1

c# ×1