HttpSessionState appears to be a typical key -> value collection, so why does it not implement the IDictionary-Interface?
Background: I am trying to output/save the Context of my ASP.NET Website when an error occurs and wanted to do this with a recursive function, that outputs a Collection and all containing Collections. Because HttpSessionState only implements ICollection and IEnumerable, I am losing the information about the keys if I want to do it in a generic manner (= working with interfaces).
IDictionaryimplies that the target collection is capable of quick lookups by key. (As far as I am aware)HttpSessionStateis just a list of items, not a dictionary style structure. As a search of that structure would take linear time there’s no reason to treat it as a dictionary. If you need a lot of quick lookups then copy the keys and values into a true dictionary. If you don’t need quick lookups, then you’ll just need to specialize for that class.There are more things to an interface than just a list of method prototypes. There are semantics that need to be preserved for an interface too. Quick lookups by key is one such non-explicit assumption for (most) consumers of any
IDictionary.