The .NET type SortedDictionary<TKey, TValue>
does not implement the interface IReadOnlyDictionary<TKey, TValue>
, although Dictionary<TKey, TValue>
does.
It is trivial to make SortedDictionary
implement IReadOnlyDictionary
by subclassing it (< 10 LOCs).
But I guess there are good reasons why the framework developers did not do it and that’s why I shouldn’t do it. What are those reasons?
1 Answer 1
Looking at MSDN today, one can see that the MSDN documentation page for SortedDictionary<TKey, TValue>
, SortedDictionary<TKey, TValue>
does implement IReadOnlyDictionary<TKey, TValue>
.
According to the internet archive, that was not the case on November 14th, 2013.
Given that information, it is likely that it was simply an oversight from Microsoft, fixed in a recent .NET point update.
-
Indeed. The MSDN page mentions ".NET 4.5.3", and today, sourceof.net shows 4.5.2, where IReadOnlyDictionary is not implemented.Martin– Martin2014年12月02日 11:35:55 +00:00Commented Dec 2, 2014 at 11:35
SortedDictionary
implementIReadOnlyDictionary
.