generic inheriting from strongly-typed Dictionary

  • Thread starter Thread starter John Grandy
  • Start date Start date
J

John Grandy

What is the correct syntax for the following :

Public Class EnumList<T> : Dictionary<int, T>
{
}

Or is this even possible ?
 
John said:
What is the correct syntax for the following :

Public Class EnumList<T> : Dictionary<int, T>
{
}

Or is this even possible ?

Use a lowercase 'P', like this:

public class EnumList<T> : Dictionary<int,T> { }

I will say that the classes in System.Collections.Generic are not
designed for inheritance. You would probably be better off with a
containment model (i.e. keep the Dictionary<,> private), or deriving
from KeyedCollection<T>.

-- Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top