Reputation: 5802
I am trying to inherit from Dictionary<K,V>
, but my problem is, that when the Dictionary.Keys are being queried, I want to override them. (that is, the KeyCollection) of the dictionary.
How can that be solved?
thanks
Upvotes: 3
Views: 225
Reputation: 100288
Dictionary<K,V>
and
IDictionary<K,V>
.or
public new YourType Keys
{
get
{
return yourVersion;
}
}
Note:
IDictionary<K,V>.Keys
has type ICollection<Key>
Dictionary<K,V>.Keys
has type Dictionary<K, V>.KeyCollection
but it's marked as sealed
so you will not be able to inherit it, so option 1 seems to be more realistic.
Upvotes: 7