小编jst*_*ark的帖子

使用接口成员实现接口

实现具有自己的接口成员的接口的正确方法是什么?(我说得对吗?)这就是我的意思:

public Interface IFoo
{
    string Forty { get; set; }
    string Two { get; set; }
}

public Interface IBar
{
    // other stuff...

    IFoo Answer { get; set; }
}

public class Foo : IFoo
{
    public string Forty { get; set; }
    public string Two { get; set; }
}

public class Bar : IBar
{
    // other stuff

    public Foo Answer { get; set; } //why doesnt' this work?
}
Run Code Online (Sandbox Code Playgroud)

我使用显式接口实现解决了我的问题,但我想知道是否有更好的方法?

c# interface

3
推荐指数
1
解决办法
185
查看次数

标签 统计

c# ×1

interface ×1