On Fri, 5 Nov 2004 09:34:32 +0200, Kejpa wrote:
I've begun trying out the .NET2005 beta and one thing that I was thrilled
about in advance was the CollectionBase class. No more selfmade Collection
CollectionBase also exists in .Net 1.1. I haven't looked at it closely,
but is the one in .Net 2.0 any different?
Why would I use a CollectionBase class as the base class of my collection if
it can't have a string as it's key?
With the addition of generics to VB.Net, you may not need to create your
own collection classes anymore. For example, suppose you have a custom
class called MyCustomClass and you need a collection of them with a string
as a key. You can use a dictionary like this using generics:
Dim oDict As New Dictionary(Of String, MyCustomClass)
Then you can add items
Dim oCustom As New MyCustomClass
oDict.Add("Key",oCustom)
And you can access the dictionary without casting:
Dim oNewCustom As MyCustomClass = oDict("Key")
The generic collection classes available include Collection, Dictionary,
KeyedCollection, KeyValuePair, LinkedList, Queue, Stack, SortedDictionary,
and others.
I would say for the vast majority of collection needs, the built in generic
classes should fit the bill. But, you can also create you own, too! I
just hope they release it in early 2005 rather than later.
--
Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.