1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Collections in VB.Net

Discussion in 'Scripting & Programming' started by Fergal1982, Apr 3, 2008.

  1. Fergal1982

    Fergal1982 Petabyte Poster

    I'm getting a little confused by how to implement collections within vb.net.

    Basically I have two classes: Parent; and Child.

    The Parent class can have one or more Child objects associated with it. I want to add a method to the Parent class that returns a collection of the Children associated with it.

    But, as I understand it, I need to implement a collections class for the Child object. Problem is, the details I've found online just seem really confusing to me. I've tried creating a class and implementing the Icollection, but i just dont understand how I need to put it together.

    Does anyone have any good links for learning this?
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  2. dmarsh

    dmarsh Terabyte Poster

    Try reading these :-



    Theres no need to implement a collection interface unless you want to create your own collection class, or data structure, for simple aggregation this is not required, just use the languages array or collection contructs or classes.

    If you mean parent and child in the literal real world sense then you probably want to model things using other OO constructs, for example a Parent and a Child are both Persons indicating inheritence. You then probably want containment by reference as some peoples parents may be other peoples children. Of course you should create inheritance heirachies based on functionality, so if there is none, in reality you would probably just model it with a single Person class.


    Martin Fowlers Analysis Patterns is an excellent introduction into such things. However patterns information is everywhere these days so buying the book is not necessary if you are prepared to dig a bit.

    Certifications: CITP, BSc, HND, SCJP, SCJD, SCWCD, SCBCD, SCEA, N+, Sec+, Proj+, Server+, Linux+, MCTS, MCPD, MCSA, MCITP, CCDH
  3. Fergal1982

    Fergal1982 Petabyte Poster

    Cheers mate, they arent actually parent/child in the literal sense, just in the sense that the parent object has multiple children objects.
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present

Share This Page