Generic Lists Desing Issue

  • Thread starter Thread starter medo
  • Start date Start date
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.
 
Back
Top