Home All Groups Group Topic Archive Search About
Author
17 Apr 2006 1:16 PM
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

Author
17 Apr 2006 1:37 PM
Craig Buchanan
looks like i want to use the DictionaryBase

Show quoteHide quote
"Craig Buchanan" <some***@microsoft.com> wrote in message
news:OnCOpEiYGHA.4760@TK2MSFTNGP03.phx.gbl...
> 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
>
Author
17 Apr 2006 5:28 PM
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?
Author
17 Apr 2006 1:45 PM
Brian Gideon
Craig,

Try the Dictionary generic class.  You can strongly type it to accept
Team values and String keys.

<http://msdn2.microsoft.com/en-us/library/xfhwa508(VS.80).aspx>

Brian

Craig Buchanan wrote:
Show quoteHide quote
> 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
Author
17 Apr 2006 2:15 PM
zacks
Brian Gideon wrote:
> Craig,
>
> Try the Dictionary generic class.  You can strongly type it to accept
> Team values and String keys.
>
> <http://msdn2.microsoft.com/en-us/library/xfhwa508(VS.80).aspx>

What's the difference between using the Dictionary class and using a
HashTable (which is how the Dictionary class is implemented)?
Author
17 Apr 2006 3:49 PM
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.

za***@construction-imaging.com wrote:
Show quoteHide quote
> Brian Gideon wrote:
> > Craig,
> >
> > Try the Dictionary generic class.  You can strongly type it to accept
> > Team values and String keys.
> >
> > <http://msdn2.microsoft.com/en-us/library/xfhwa508(VS.80).aspx>
>
> What's the difference between using the Dictionary class and using a
> HashTable (which is how the Dictionary class is implemented)?