473,385 Members | 1,813 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,385 software developers and data experts.

collection question

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
Apr 17 '06 #1
5 840
looks like i want to use the DictionaryBase

"Craig Buchanan" <so*****@microsoft.com> wrote in message
news:On**************@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

Apr 17 '06 #2
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:
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


Apr 17 '06 #3

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)?

Apr 17 '06 #4
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:
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)?


Apr 17 '06 #5
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?

Apr 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Generic Usenet Account | last post by:
To settle the dispute regarding what happens when an "erase" method is invoked on an STL container (i.e. whether the element is merely removed from the container or whether it also gets deleted in...
5
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use...
18
by: Scott | last post by:
I have a collection where the items in the collection are dates. I want to iterate over the collection and build a value list string for the rowsource of a listbox. The dates in the collection are...
7
by: Pete Davis | last post by:
A different question this time. I have a DataGrid bound to a collection. Is there any way for me to allow sorting? The DataGrid.AllowSorting=true doesn't work, but that's probably because it can't...
4
by: bkazlak | last post by:
Hello, I have a quick question might help me understand garbage collection. let's say I'm having a static collection of objects in one class, so this collection should be cached and present...
3
by: JJ | last post by:
Hi, I noticed in a sample app source code that the app made use of a class for example a user class and then had the user objects that got created stuffed into a user collection. I was wondering...
16
by: Ben Hannon | last post by:
Hi, I'm writting a COM Class in VB.NET to be used in a VB6 project (Tired of the VB6 hassles with cloning and serializing an object). All my classes I need cloneable/serializable are now in a...
34
by: Craig Buchanan | last post by:
Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string. I wrote my own class that...
54
by: MLH | last post by:
I use A97 and do not always insert line numbers while writing procedures. I find it necessary to go back and add them later to aid in debugging. Nearly 3 years ago, something was mentioned in...
158
by: pushpakulkar | last post by:
Hi all, Is garbage collection possible in C++. It doesn't come as part of language support. Is there any specific reason for the same due to the way the language is designed. Or it is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.