|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
collection questioni'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 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 > 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? 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 Brian Gideon wrote:
> Craig, What's the difference between using the Dictionary class and using a> > 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> HashTable (which is how the Dictionary class is implemented)? 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)?
Is there a Filename.IsValid function anywhere?
radio button user settings knowing when file has been totally transferred urgent: formatting XL cells Reusing VB.NET Form dialogs in VC apps Working with data adapter/binding source at runtime Combobox, Count Entries Successfully executing queries Registry Help Needed Looking for a line graph control. |
|||||||||||||||||||||||