Instead of using Dictionary<TKey,TValue> I want some type of collection class that can use a property of the value as the key, is there something like this?
Instead of using Dictionary<TKey,TValue> I want some type of collection class that can use
Share
Yes, there is –
System.Collections.ObjectModel.KeyedCollection<TKey, TValue>.That’s abstract, and there are no concrete derived classes in the framework as far as I can see, but all you need to implement is
GetKeyForItemas far as I can see. For example, you could do this with a delegate: