我有两个这样的接口:
public interface IMyInterface1
{
string prop1 { get; set; }
string prop2 { get; set; }
}
public interface IMyInterface2
{
string prop1 { get; set; }
IList<IMyInterface1> prop2 { get; set; }
}
我定义了两个实现接口的类:
public class MyClass1 : IMyInterface1
{
public string prop1 {get; set;}
public string prop2 {get; set;}
}
public class MyClass2 : IMyInterface2
{
public string prop1 {get; set;}
public IList<MyClass1> prop2 {get; set;}
}
但是当我构建代码时,我收到以下错误消息:
“ClassLibrary1.MyClass2”没有实现接口成员“ClassLibrary1.IMyInterface2.prop2”。“ClassLibrary1.MyClass2.prop2”无法实现“ClassLibrary1.IMyInterface2.prop2”,因为它没有匹配的返回类型“System.Collections.Generic.IList”
如何在我的班级上实现 IMyInterface2 的“IList prop2”?