Results 1 to 2 of 2

Thread: adding a collection to an arraylist collection

  1. #1

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    adding a collection to an arraylist collection

    for instance, i have a people class and a people collection.

    i would like to create a phone collection which consists of
    phone class and phone collection and then attach this to the
    people class object.

    so, in effect, i can call each people item and have the phone collection
    as a property where i can iterate through this phone collection.

    how can i make this happen?

    thanks in advance.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: adding a collection to an arraylist collection

    Ideally you'd have a PhoneNumber type and a PhoneNumberCollection type. You would create PhoneNumber objects and add them to a PhoneNumberCollection object. You'd then also have a Person type and a PersonCollection type. The Person class would have a ReadOnly property of type PhoneNumberCollection named PhoneNumbers.

    Please always specify your version. If you're using .NET 1.x then you'd derive the collection classes from CollectionBase. If you're using .NET 2.0 then you'd derive them from Collection(Of Person) and Collection(Of PhoneNumber).
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width