Generic Lists Desing Issue

M

medo

Generic Lists are great!
But I think you missed a opportunity.

Here is my problem.
I made a Collection "Family: List<Person> "
which will contain 'Family'. I wanted to override the Add method so you can
only add persons whose Parents or Childeren are already in the list, but the
Add method is not virtual!

The Add method of Arraylist is virtual and I see no reason for the generic
counterpart not to be.

My work around is to create my own GenericList that has a private List<T>
and duplicate all IList<T> members and make them virtual, but still it
should have been there all along.

I see no reason why List<> or all other generic collections have no virtual
methods, is there? Maybe speed, but that wasn't an issue with ArrayList so
it shouldn't be with generic collections either.
 

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

Top