473,388 Members | 904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 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 937
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Bernardo Heynemann | last post by:
How can I use Generics? How can I use C# 2.0? I already have VS.NET 2003 Enterprise Edition and still cant use generics... Im trying to make a generic collection myCollection<vartype> and...
2
by: Mr.Tickle | last post by:
So whats the deal here regarding Generics in the 2004 release and templates currently in C++?
23
by: Luc Vaillant | last post by:
I need to initialise a typed parameter depending of its type in a generic class. I have tried to use the C++ template form as follow, but it doesn't work. It seems to be a limitation of generics...
4
by: Gazarsgo | last post by:
This seems to be a bit of a contradiction, but how can I construct a Generic class using a System.Type variable that is assigned at run time? Is there some parallel to the Generics concept that...
1
by: Kevin S. Goff | last post by:
Hi, all, Hopefully this will make sense: I have 2 classes that implement the same generic interface. public interface IAgingReport<T> { T GetAgingReport(DateTime dAsOfDate); }
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.