Guest Imogen Posted August 24, 2002 Posted August 24, 2002 Hi, when using VB6 I used to use the collection object and put in in a wrapper to facilitate my own collections e.g. collection: wrapper around VB's collection class object: my own custom object. How do I achieve this in .Net, including exposing the enumeration. thanks Imogen Quote
*Gurus* Thinker Posted August 24, 2002 *Gurus* Posted August 24, 2002 You have to inherit one of the System.Collections classes and extend it however you need. But, with all the options available in the System.Collections namespace, it is hard to believe you would need to extend one. There is an ArrayList, BitArray, Dictionary, Hashtable, Queue, SortedList, and Stack. It is a huge improvement over VB6. Quote Posting Guidelines
*Experts* Merrion Posted December 6, 2002 *Experts* Posted December 6, 2002 To make a type safe collection, inherit from the DictionaryBase collection and overload the properties Item, Add and Contains e.g.: Public Class Vehicle Public LicencePlate As String '\\This is unique... Public Make As String End Class Public Class VehiclesDictionary Inherits Collections.DictionaryBase Public Overloads Property Item(ByVal LicencePlate As String) As Vehicle Get Return CType(dictionary.Item(LicencePlate), Vehicle) End Get Set (Byval Value As Vehilce) dictionary.Item(Value.LicencePlate) = Value End Set End Property End Class Hope this is useful, Duncan Quote Printer Monitor for .NET? - see Merrion Computing Ltd for details
*Gurus* divil Posted December 6, 2002 *Gurus* Posted December 6, 2002 If you just need a strongly-typed collection, you can inherit from CollectionBase. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.