473,399 Members | 2,146 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,399 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 938
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 can´t use generics... I´m 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.