为什么 IDictionary<TKey, TValue> 不实现 IReadOnlyDictionary<TKey, TValue>?

Har*_*lse 6 c# dictionary readonly-collection

我注意到Dictionary Class实现IDictionary<TKey,?TValue>以及IReadOnlyDictionary<TKey,?TValue>.

但是IDictionary 接口没有实现IReadOnlyDictionary<TKey,?TValue>.

这意味着如果我的类有一个IDictionary<TKey,?TValue>, 并且我需要传递一个 ,IReadOnlyDictionary<TKey,?TValue>我应该为此创建一个适配器,或者使用不同的解决方法。

恕我直言,每个具有 an 功能的类IDictionary<TKey,?TValue>也具有IReadOnlyDictionary<TKey,?TValue>.

他们是否只是忘记了实现它,或者是否有真正有意义的类实现IDictionary<TKey,?TValue>而不能具有有意义的实现IReadOnlyDictionary<TKey,?TValue>