471,330 Members | 1,209 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

using Generics

Hello!

I just wonder in .NET 2.0 Generics was added.
Before generics existed it was an advantage to get strongly typed methods so
we derived collection classes from CollectionBase
where we had to implement add remove and so on.

But now when generic classes can be used I can't see any point in ever using
this CollectionBase any more.

Do you agree with me?

//Tony
Jun 27 '08 #1
3 882
On Jun 16, 11:00 am, "Tony" <johansson.anders...@telia.comwrote:
I just wonder in .NET 2.0 Generics was added.
Before generics existed it was an advantage to get strongly typed methods so
we derived collection classes from CollectionBase
where we had to implement add remove and so on.

But now when generic classes can be used I can't see any point in ever using
this CollectionBase any more.

Do you agree with me?
There's little reason to use the nongeneric CollectionBase. However,
there are additional reasons to use something *like* CollectionBase
(and I can't remember the generic equivalent right now) - if you want
to be able to validate items as they are added, hook up events etc.

Jon
Jun 27 '08 #2
However,
there are additional reasons to use something *like* CollectionBase
(and I can't remember the generic equivalent right now)
Probably System.Collections.ObjectModel.Collection<T>

Unlike List<T>, this has virtual methods as extension points.

Marc
Jun 27 '08 #3
On Jun 16, 12:20 pm, Marc Gravell <marc.grav...@gmail.comwrote:
However,
there are additional reasons to use something *like* CollectionBase
(and I can't remember the generic equivalent right now)

Probably System.Collections.ObjectModel.Collection<T>

Unlike List<T>, this has virtual methods as extension points.
Yup, that's the one :)

Jon
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

27 posts views Thread by Bernardo Heynemann | last post: by
2 posts views Thread by Mr.Tickle | last post: by
23 posts views Thread by Luc Vaillant | last post: by
4 posts views Thread by Gazarsgo | last post: by
1 post views Thread by Kevin S. Goff | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.