考虑 C# 片段:
interface Contract
{
ICollection<string> Coll { get; }
}
class Implementation : Contract
{
public List<string> Coll { get; } //this declaration is mandatory for other reason
}
为什么实施不实施合同?
List<string>
工具ICollection<string>
真实案例
//Entity Framework
public partial class ApplicationUser : IdentityUser<Guid>
{
...
public virtual ICollection<Message> Messages { get; set; }
}
//Breeze.Sharp Entity
public partial class ApplicationUser : BaseEntity
{
...
public NavigationSet<Message> Messages
{
get { return GetValue<NavigationSet<Message>>(); }
}
}
如何找到两个类都实现的接口?