gpt4 book ai didi

C# List 隐藏属性?

转载 作者:太空宇宙 更新时间:2023-11-03 19:27:31 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How does List<T> make IsReadOnly private when IsReadOnly is an interface member?

好吧,这让我抓狂。 List<T>工具 IList<T> .然而,

IList<int> list = new List<int>();
bool b = list.IsReadOnly;
bool c = ((List<int>)list).IsReadOnly; // Error

错误是:

'System.Collections.Generic.List' does not contain a definition for 'IsReadOnly' and no extension method 'IsReadOnly' accepting a first argument of type 'System.Collections.Generic.List' could be found (are you missing a using directive or an assembly reference?)

这怎么可能?这不是违反了我们告诉大家的关于不隐藏成员的规则吗?这里的实现细节是什么?

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