我有以下界面:
public interface IModel<T>
{
List<T> responseIds { get; set; }
}
我有一个实现接口的泛型类:
class SFDCResponse<T> : SFDCBaseResponse, IModel<T>
{
public List<T> responseIds;
}
最后,我定义了一个类:
class SFDCAccounts : SFDCResponse<MyClass> { }
但是,在编译时我收到以下错误:
SFDCResponse<T> does not implement interface member IModel<T>.responseIds
是否不可能让泛型类继承通用接口并让编译器验证该类是否为编译时间?
答案 0 :(得分:0)
responseIds是接口中的Property和实现类中的Field。使它成为一个财产,这应该解决你的问题。
答案 1 :(得分:0)
好吧,只看我自己的帖子,我意识到我的SFDCResponse类将responseIds实现为字段而不是属性。我刚才更正了:
class SFDCResponse<T> : SFDCBaseResponse, IModel<T>
{
public List<T> responseIds { get; set; }
}
该应用已编译完成。有时只是通过这个过程得到你自己的答案。