gpt4 book ai didi

c# - 为什么 IList 实现 IEnumerable 和 ICollection 而 ICollection 本身实现 IEnumerable

转载 作者:太空狗 更新时间:2023-10-29 22:26:10 24 4
gpt4 key购买 nike

<分区>

为什么IList是这样定义的?

public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable

public interface ICollection<T> : IEnumerable<T>, IEnumerable

public interface IEnumerable<T> : IEnumerable

不就是这样吗

public interface IList<T> : ICollection<T>

所以,为了测试我创建了这些接口(interface),只是为了确定它是否有效!

public interface IOne
{
string One();
}

public interface ITwo : IOne
{
string Two();
}

public interface IThree : ITwo, IOne
{
string Three();
}

虽然它非常好,但 Resharper 提示“冗余接口(interface)”。

对于 Microsoft 继续进行此实现的任何想法?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com