A question about interface inheritance in .NET

前端 未结 4 960
慢半拍i
慢半拍i 2021-01-06 18:11

Let\'s take the interface IQueryable for example:

public interface IQueryable : IQueryable, IEnumerable;

Sin

4条回答
  •  清歌不尽
    2021-01-06 18:24

    Mentioning the grandparent (and higher ancestors) in the declaration is not strictly necessary, but since the parent, being an interface, didn't actually implement the grandparent, its better to mention the grandparent in the declaration of the grandchild to improve documentation for the eventual implementer.

    Thats why, in case of concrete implementations in the ancestry , you see the following in MSDN:

    public class Button : ButtonBase,IButtonControl
    

    and not the following ...

    public class Button : ButtonBase,Control,Component,MarshalByRefObject,Object
    

提交回复
热议问题