collectionbase vs generic

  • Thread starter Thread starter Andreas Zita
  • Start date Start date
A

Andreas Zita

Im new to 2.0 and have a question about generic collections.

In 1.1 I used to create custom collections derived from collectionbase. For
instance ItemCollection : CollectionBase. Then I would also have collections
such as MovieCollection or ImageCollection deriving from ItemCollection
where ItemCollection was handling methods such as FindItemById(int id).

In this case converting from a MovieCollection to a ItemCollection was no
problem and could be done implicitly. I could for instance have a base class
Database having a field ItemCollection m_items and then initiating it as a
MovieCollection in a derived MovieDatabase-class.

How is this scenario possible in 2.0 with generics instead of
collectionbase?

I have noticed that ItemCollection<ItemType> m_items =
(ItemCollection<ItemType>)new ItemCollection<MovieType> is not possible even
though Movie inherits from Item.

Should I stick to collectionbase in this case?

/Andreas Zita
 
Back
Top