且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

接口不能声明类型

更新时间:2021-09-06 04:22:19

由于错误指示,你只需要拉状态接口之外。据我所知,它打破封装,但真的没有办法解决这个。我建议你​​换状态的名称的东西表明一个强大的关系的事情 - ThingStatus 应该做的伎俩

As the error indicates, you just have to pull the definition of Status outside of the interface. I understand that it breaks encapsulation, but there's really no way around this. I suggest you change the name of Status to something which indicates a strong relation to Thing -- ThingStatus should do the trick.

enum ThingStatus { Accepted, Denied, Pending };

public interface Thing
{
    ThingStatus status { get; }
    etc...
}