Collection wrapper

  • Thread starter Thread starter Frank Rizzo
  • Start date Start date
F

Frank Rizzo

ArrayList suffers from the same effect as the vb6 collection object.
Once you add an object to the collection, you lose the intellisense for
that object. Has anyone seen any wrappers for the collection-like
objects in .NET that preserve intellisense?

Thanks
 
Ah, and if you want to use normal ArrayList - just typecast the items to
your class.
 
Frank,
Have you looked at the System.Collections.CollectionBase base class?

It allows you to define a type safe collection that is based on an
underlying ArrayList. A type safe collection among other things enables
intellisense.

Of course you need to manually create the collections, however there are
tools available that will automate the creation of the type safe
collections, such as the one Miha Markic pointed out.

Note there is also a System.Collections.DitionaryBase if you want a type
safe collection based on an underlying HashTable.

Note: when C# 2.0 (Whidbey, aka VS.NET 2004) ships later in 2004, we will
have Generics which will simplify creating type safe collections.

Hope this helps
Jay
 
Thank you both. This clears a few things up.
Frank,
Have you looked at the System.Collections.CollectionBase base class?

It allows you to define a type safe collection that is based on an
underlying ArrayList. A type safe collection among other things enables
intellisense.

Of course you need to manually create the collections, however there are
tools available that will automate the creation of the type safe
collections, such as the one Miha Markic pointed out.

Note there is also a System.Collections.DitionaryBase if you want a type
safe collection based on an underlying HashTable.

Note: when C# 2.0 (Whidbey, aka VS.NET 2004) ships later in 2004, we will
have Generics which will simplify creating type safe collections.

Hope this helps
Jay
 
You'll be happy to know that C# 2.0 should solve this "problem" with
Generics. I'm not sure how well the intellisense will work, but I assume MS
will do a good job with it.

You'll just define ArrayList<Customer> and you have an ArrayList that only
holds Customers. Of course, if you are writing some sort of library, then a
custom collection is still the way to go.

I'm sure that hearing this'll just make you become as impatient as
I...waiting for generics. I'm almost drooling, I am.

--Matthew W. Jackson
 
I'm sure that hearing this'll just make you become as impatient as
I...waiting for generics. I'm almost drooling, I am.

Well, make sure to keep enough water (beer?) in the house - as it is
probably a year away ;-)
 
Back
Top