How do I inherit from Dictionary?

c#, collections, inheritance

Solution

You were close, you just need to remove the type parameters from the constructors.

class Foo<TKey,TValue> : Dictionary<TKey, TValue>
{   
    Foo():base(){}
    Foo(int capacity):base(capacity){}
}

To override a method you can use the override keyword.

Problem

I want all the functionality of `Dictionary<TKey,TValue>` but I want it as `Foo<TKey,TValue>`. How should I go about doing this? Currently I am using ``` class Foo<TKey,TValue> : Dictionary<TKey, TValue> { /* I'm getting all sorts of errors because I don't know how to overload the constructors of the parent class. */ // overloaded methods and constructors goes here. Foo<TKey,TValue>():base(){} Foo<TKey,TValue>(int capacity):base(capacity){} } ``` What is the right way to overload constructors and methods of the parent class? NOTE:I think I have misused the word 'overload' please correct it or suggest correction.

Original source