开发者

Explicitly inherit 'grand parent' interface in inheritance list

开发者 https://www.devze.com 2023-02-08 19:08 出处:网络
I was having a look at the IOrderedQueryable<T> interface and noticed that it inherits from IQueryable<T> but also from System.Collections.Generic.IEnumerable<T>, IQueryable and IEnu

I was having a look at the IOrderedQueryable<T> interface and noticed that it inherits from IQueryable<T> but also from System.Collections.Generic.IEnumerable<T>, IQueryable and IEnumerable

public interface IOrderedQueryable<T> : 
    System.Linq.IQueryable<T>,
    System.Collections.Generic.IEnumerable<T>,
    System.Linq.IOrderedQueryable,
    System.Linq.IQueryable,
    System.Collections.IEnumerable 

My question: Since IQueryable<T> already does inheri开发者_JAVA技巧t from these other interfaces why does IOrderedQueryable have to specify/inherit from these explicitly? Why not just inherit from System.Linq.IQueryable<T> and System.Linq.IOrderedQueryable.

Obviously this question is applicable to interface inheritance in general also.


Classes automatically inherit these 'grand parent' interfaces, so you do not have to specify them explicitly. So, given these interfaces:

interface IBase {}
interface IChild: IBase {}

Either of these are fine:

interface IGrandChild: IChild {}
interface IGrandChild: IBase, IChild {}

The documentation just lists the ancestor interfaces for convenience and clarity: "It is much more clear for the documentation to be complete all in one place than to make you search through ten different pages to find out what the full interface set is."

0

精彩评论

暂无评论...
验证码 换一张
取 消