collection question

C

Craig Buchanan

i'm sure this question has been asked a number of times, but i can't seem to
located the answer...

what is the recommend way to build a custom collection in vb 2005, so that i
can have have Item property that returns an instance of a class by a key
value? for example, Teams("sonics").Wins.Value=10

should i be using a sortedlist rather than the collectionbase? i'd rather
not use the compatibility features of the
Microsoft.VisualBasic namespace.

thanks.

craig buchanan
 
B

Brian Gideon

Dictionary is generic so you can specify what types are acceptable for
the key and value. Hashtable accepts any object. The advantage of
using the Dictionary is that you get compile time type checking and
faster performance since value types don't have to be boxed/unboxed.
Of course, Dictionary is only available in .NET 2.0.
 
C

Chris Dunaway

Why go through the trouble of building your own class when, as Brian
says, you can use a Dictionary(Of T) generic to do the same thing?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top