I'm wondering which collection-type in System.Collections.Generic will support this scenario, if there is one:
Public Class MyCollectionBase(Of ItemType, KeyType)
Inherits System.Collection.Generic.???
Default Public Shadows ReadOnly Property Item(ByVal key as KeyType) as ItemType
Get
....
End Get
End Property
End Class
In the past, I've used this sort of behavior with Configuration objects inheriting System.Configuration.ConfigurationElementType, like this:
Default Public Shadows ReadOnly Property Item(ByVal id As String) As Element
Get
Return CType(BaseGet(id), Element)
End Get
End Property
In this case, though, my collections have nothing to do with configuration, and I need the elements to be generic, as well as the element key/ID.
Thanks in advance.
EDIT: Accepting Joel's answer. I feel like an idiot. For some reason I was glued to the idea that I wanted to stick with an implementation of ICollection that wasn't an IDictionary, probably because I'm refactoring classes that were originally meant to be used with NHibernate mappings. Dictionary is it, of course. I will be hiding in the corner if anyone needs me.