VB 2005 Colletions Issue  
Author Message
Gary Spence





PostPosted: .NET Base Class Library, VB 2005 Colletions Issue Top

HI Im inheriting from a System.Colletions.CollectionBase as a base class for my collection, and would like to use a string key to itemise each element I put into my collection, but you cant supply a key when adding elements to the CollectionBase collection, any assistance or other suggestions would be much appreciated. Thank You


.NET Development27  
 
 
David M. Kean - MSFT





PostPosted: .NET Base Class Library, VB 2005 Colletions Issue Top

Have a look at the generic System.Collections.Generic.Dictionary<TKey, TValue> class, this is a new class for .NET 2.0.



Dim instance As New Dictionary(Of String, String)
instance.Add("Key", "Value")



 
 
RizwanSharp





PostPosted: .NET Base Class Library, VB 2005 Colletions Issue Top

If you are working in .Net 2.0 then why dont you use Generic Collection class (Dictionary)

It lets you add a Key, and a Value in it!

I hope this is better than creating your own!

Best Regards,



 
 
Gary Spence





PostPosted: .NET Base Class Library, VB 2005 Colletions Issue Top

Thank You David.... it worked a treat !

 
 
Gary Spence





PostPosted: .NET Base Class Library, VB 2005 Colletions Issue Top

Thank You RizwanSharp... it worked a treat !

 
 
RizwanSharp





PostPosted: .NET Base Class Library, VB 2005 Colletions Issue Top

Thank You RizwanSharp... it worked a treat !

You are Always Welcome ;)

Best Regards,