C#.NET接口的多级实现
在使用BindingList时,我发现自己在钻研System.Collections.Generic。我不了解以下接口实现:C#.NET接口的多级实现,c#,.net,generics,inheritance,interface,C#,.net,Generics,Inheritance,Interface,在使用BindingList时,我发现自己在钻研System.Collections.Generic。我不了解以下接口实现: public interface ICollection<T> : IEnumerable<T>, IEnumerable public interface ISet<T> : ICollection<T>, IEnumerable<T>, IEnumerable 公共接口ICollection:IEnumer
public interface ICollection<T> : IEnumerable<T>, IEnumerable
public interface ISet<T> : ICollection<T>, IEnumerable<T>, IEnumerable
公共接口ICollection:IEnumerable,IEnumerable
公共接口ISet:ICollection、IEnumerable、IEnumerable
为什么
ISet<T>
ISet
实施
IEnumerable<T>, IEnumerable
IEnumerable,IEnumerable
ICollection什么时候已经完成了?下列情况难道不可以接受吗
public interface ICollection<T> : IEnumerable<T>, IEnumerable
public interface ISet<T> : ICollection<T>
公共接口ICollection:IEnumerable,IEnumerable
公共接口ISet:ICollection
任何有助于理解这一点的帮助都将不胜感激。谢谢 我假设您拥有来自或其他文档源的接口声明。虽然
ISet
不必显式实现IEnumerable
和IEnumerable
是正确的,正如您在
公共接口ISet:ICollection
。。。文档仍然包含完整的列表,以方便开发人员,因此他们知道ISet实现了哪些接口,即使只是通过继承实现。通过一个可能很长的继承层次结构可能不会增强这样一个文档的好处。我假设您有来自或其他文档源的接口声明。虽然
ISet
不必显式实现IEnumerable
和IEnumerable
是正确的,正如您在
公共接口ISet:ICollection
。。。文档仍然包含完整的列表,以方便开发人员,因此他们知道ISet实现了哪些接口,即使只是通过继承实现。浏览一个可能很长的继承层次结构可能不会提高这样一个文档的好处。您在寻找什么来源?看看源代码:-只是VisualStudio向您展示了层次结构中的所有接口。Microsoft喜欢重复继承的接口声明,这是优秀的自我文档。这对代码或运行时行为没有任何影响。谢谢@HansPassant,你的评论是我真正想要的漂亮、简洁的答案。你在看什么来源?看看源代码:-只是VisualStudio向您展示了层次结构中的所有接口。Microsoft喜欢重复继承的接口声明,这是优秀的自我文档。这对代码或运行时行为没有任何影响。谢谢@HansPassant,你的评论是我真正想要的漂亮、简洁的答案。我认为这是一个方便/可读的特性,但我想我应该问问社区。谢谢@Adrian!我认为这是一个方便/易读的特性,但我想我应该问问社区。谢谢@Adrian!
public interface ISet<T> : ICollection<T>