Link to home
Start Free TrialLog in
Avatar of CesarGon
CesarGonFlag for Spain

asked on

Iterating user collections

I have a class Chair in my system. Now I want to deal with typed collections of chairs, so I have defined a ColChair class, with a collection-like interface: Add, Remove, Item and Count. I have made Item the defaut property. The problem is I can't iterate the collection with a "For Each" construct; it crashes at run-time:

  Dim col As New ColChair
  'fill col with Chair objects.
  Dim ch As Chair
  For Each ch In col 'this line crashes.
    'do something with ch.
  Next ch

Any ideas?.

Regards,
César.
Avatar of MikeP090797
MikeP090797

What error to you get?
ASKER CERTIFIED SOLUTION
Avatar of Belgarion_aus
Belgarion_aus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CesarGon

ASKER

Thanks for your reply. It really works!. To satisfy my curiosity, please may you tell me where you learnt the solution?.

Regards,
César.